@openchamber/web 1.18.2 → 1.18.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/bin/lib/commands-models.js +1 -1
  2. package/dist/assets/{CodeMirrorCommentWidgets-CxcJ5x9h.js → CodeMirrorCommentWidgets-4qZbrEXU.js} +1 -1
  3. package/dist/assets/{CommitSection-C9sBBYAJ.js → CommitSection-MJmntVPJ.js} +1 -1
  4. package/dist/assets/{DiagramEditor-C7nUw7p3.js → DiagramEditor-jnG3Hbxg.js} +1 -1
  5. package/dist/assets/{DiagramView-cYxZP-HS.js → DiagramView-CFXxgg_a.js} +1 -1
  6. package/dist/assets/{DiffView-1zd0slLu.js → DiffView-DZIoOnV7.js} +2 -2
  7. package/dist/assets/FilesView-BKL6YlKG.js +14 -0
  8. package/dist/assets/{GitView-OSVIn5V1.js → GitView-DBFrDDBv.js} +1 -1
  9. package/dist/assets/{JsonTreeView-Kgepz4pR.js → JsonTreeView-DLW2Wy1g.js} +1 -1
  10. package/dist/assets/MarkdownImageGallery-DKIylIK7.js +1 -0
  11. package/dist/assets/MarkdownRendererImpl-CLv8hxvv.js +12 -0
  12. package/dist/assets/OnboardingScreen-D2Y6djMw.js +1 -0
  13. package/dist/assets/{PatchDiff-Cddz02Ya.js → PatchDiff-BuLPx7AN.js} +1 -1
  14. package/dist/assets/{PierreDiffViewer-B5k0KvPW.js → PierreDiffViewer-BHm4Yr0X.js} +2 -2
  15. package/dist/assets/{PlanView-BYgHBHDt.js → PlanView-ZYEJn8A_.js} +3 -3
  16. package/dist/assets/{SessionSwitcherDropdown-ig2OT22Z.js → SessionSwitcherDropdown-rro-SsaO.js} +1 -1
  17. package/dist/assets/SettingsView-5RmswFZe.js +28 -0
  18. package/dist/assets/{SettingsWindow-CNHM8ifT.js → SettingsWindow-BZhAYFdS.js} +1 -1
  19. package/dist/assets/{ToolOutputDialog-DrGeYq2p.js → ToolOutputDialog-Za6V4VMJ.js} +7 -7
  20. package/dist/assets/{ToolPartDiffPreview-BRmPpe94.js → ToolPartDiffPreview-BL-9ixyC.js} +1 -1
  21. package/dist/assets/{VirtualizedFileDiff-Dcu8Q-5P.js → VirtualizedFileDiff-CwGocYQd.js} +1 -1
  22. package/dist/assets/{WalkthroughView-HStEYdD2.js → WalkthroughView-5DyvN03T.js} +2 -2
  23. package/dist/assets/{computeVirtualFileMetrics-DQE7R9IY.js → computeVirtualFileMetrics-Da00Jg7M.js} +2 -2
  24. package/dist/assets/contextPanelEmbeddedChat-B-bSg3P5.js +1 -0
  25. package/dist/assets/de-u7gSnqWs.js +9 -0
  26. package/dist/assets/es-T9O7aAOr.js +15 -0
  27. package/dist/assets/fr-Oor7ewbE.js +13 -0
  28. package/dist/assets/index-BzIpNlNE.css +1 -0
  29. package/dist/assets/{index-BgQEgA2a.js → index-C0yNhuZw.js} +1 -1
  30. package/dist/assets/index-DRpChWux.js +7 -0
  31. package/dist/assets/{isDiffPlainText-XyBCe4eD.js → isDiffPlainText-D9YpoLrV.js} +1 -1
  32. package/dist/assets/{isFilePlainText-JbqDfa3n.js → isFilePlainText-gTibdNIe.js} +1 -1
  33. package/dist/assets/ja-DHpqbVmr.js +15 -0
  34. package/dist/assets/ko-CwLkS3nx.js +15 -0
  35. package/dist/assets/{main-LfcbGv7C.js → main-D7UcL3VQ.js} +2 -2
  36. package/dist/assets/main-DPMd2iKS.js +915 -0
  37. package/dist/assets/markdownCore-DDrHVneM.js +2 -0
  38. package/dist/assets/{miniChat-CUp_elRz.js → miniChat-O_GVoEbc.js} +2 -2
  39. package/dist/assets/{mobile-CBSN7BsH.js → mobile-Br4TtAqc.js} +2 -2
  40. package/dist/assets/{patchFileDiff-DCIXUHRJ.js → patchFileDiff-KNkxM1C1.js} +2 -2
  41. package/dist/assets/{pl-tHTP6XQx.js → pl-CcZILN8q.js} +4 -4
  42. package/dist/assets/pt-BR-DYHhVK6o.js +15 -0
  43. package/dist/assets/{renderElectronMiniChatApp-eZl-5STF.js → renderElectronMiniChatApp-CJpdxTT1.js} +2 -2
  44. package/dist/assets/renderMobileApp-toj9cXoh.js +25 -0
  45. package/dist/assets/runtimeEndpointReset-BVmispdD.js +13 -0
  46. package/dist/assets/scheduledTasksApi-ByKya3Un.js +1 -0
  47. package/dist/assets/{shikiHighlight-eU8abJ3T.js → shikiHighlight-C7LTbwFx.js} +1 -1
  48. package/dist/assets/uk-BA2kZR38.js +15 -0
  49. package/dist/assets/{useAppFontEffects-Bbpz77To.js → useAppFontEffects-BikB6enL.js} +138 -138
  50. package/dist/assets/useInlineCommentController-CYPvYJDt.js +2 -0
  51. package/dist/assets/{vendor-codemirror-language-data-Dzt9rWZZ.js → vendor-codemirror-language-data-CLHw8NWn.js} +2 -2
  52. package/dist/assets/{vendor-marked-i_gIkIP3.js → vendor-marked-CX41MkDF.js} +1 -1
  53. package/dist/assets/{web-components-DGvnI0zx.js → web-components-GMc3oR3i.js} +1 -1
  54. package/dist/assets/zh-CN-dlOQK6v9.js +15 -0
  55. package/dist/assets/zh-TW-BnqQ-WL5.js +15 -0
  56. package/dist/index.html +4 -4
  57. package/dist/mini-chat.html +3 -3
  58. package/dist/mobile.html +3 -3
  59. package/package.json +2 -2
  60. package/server/index.js +65 -19
  61. package/server/lib/agent-tool/DOCUMENTATION.md +21 -6
  62. package/server/lib/agent-tool/runtime.js +90 -16
  63. package/server/lib/agent-tool/runtime.test.js +86 -0
  64. package/server/lib/browser-control/DOCUMENTATION.md +50 -0
  65. package/server/lib/browser-control/broker.js +154 -0
  66. package/server/lib/browser-control/broker.test.js +191 -0
  67. package/server/lib/browser-control/routes.js +48 -0
  68. package/server/lib/browser-control/routes.test.js +108 -0
  69. package/server/lib/dev-servers/parse.js +203 -0
  70. package/server/lib/dev-servers/parse.test.js +174 -0
  71. package/server/lib/dev-servers/routes.js +135 -0
  72. package/server/lib/dev-tunnel/DOCUMENTATION.md +57 -0
  73. package/server/lib/dev-tunnel/client.js +193 -0
  74. package/server/lib/dev-tunnel/runtime.js +189 -0
  75. package/server/lib/dev-tunnel/tunnel.test.js +291 -0
  76. package/server/lib/git/credentials.js +0 -33
  77. package/server/lib/github/DOCUMENTATION.md +1 -1
  78. package/server/lib/markdown-image-grants/DOCUMENTATION.md +36 -0
  79. package/server/lib/markdown-image-grants/routes.js +340 -0
  80. package/server/lib/markdown-image-grants/routes.test.js +221 -0
  81. package/server/lib/openchamber-control/DOCUMENTATION.md +9 -0
  82. package/server/lib/openchamber-control/actions.js +33 -1
  83. package/server/lib/openchamber-control/screenshots.js +83 -0
  84. package/server/lib/openchamber-control/screenshots.test.js +84 -0
  85. package/server/lib/openchamber-control/service.js +141 -2
  86. package/server/lib/openchamber-control/service.test.js +55 -0
  87. package/server/lib/opencode/core-routes.js +31 -52
  88. package/server/lib/opencode/core-routes.test.js +37 -9
  89. package/server/lib/opencode/feature-routes-runtime.js +15 -0
  90. package/server/lib/opencode/server-startup-runtime.js +22 -1
  91. package/server/lib/opencode/server-startup-runtime.test.js +44 -0
  92. package/server/lib/opencode/settings-helpers.js +3 -9
  93. package/server/lib/projects/project-config.js +181 -2
  94. package/server/lib/projects/project-config.test.js +295 -0
  95. package/server/lib/quota/DOCUMENTATION.md +4 -2
  96. package/server/lib/quota/credentials/providers.js +0 -7
  97. package/server/lib/quota/credentials/store.js +11 -1
  98. package/server/lib/quota/credentials/store.test.js +9 -1
  99. package/server/lib/quota/providers/opencode-go.js +35 -35
  100. package/server/lib/quota/providers/opencode-go.test.js +52 -7
  101. package/server/lib/quota/routes.js +0 -2
  102. package/server/lib/relay/DOCUMENTATION.md +2 -0
  103. package/server/lib/relay/tunnel-host.js +157 -33
  104. package/server/lib/relay/tunnel-host.test.js +147 -0
  105. package/server/lib/scheduled-tasks/DOCUMENTATION.md +49 -0
  106. package/server/lib/scheduled-tasks/issue-2710-double-execution.test.js +488 -0
  107. package/server/lib/scheduled-tasks/routes.js +6 -0
  108. package/server/lib/scheduled-tasks/runtime.js +369 -108
  109. package/server/lib/scheduled-tasks/service.js +7 -1
  110. package/server/lib/scheduled-tasks/service.test.js +20 -0
  111. package/server/lib/walkthrough/index.js +0 -2
  112. package/server/sse-routes.test.js +3 -0
  113. package/dist/assets/FilesView-WkxsWHBE.js +0 -14
  114. package/dist/assets/MarkdownRendererImpl-CKAsRfIk.js +0 -12
  115. package/dist/assets/OnboardingScreen-BCgYA7J5.js +0 -1
  116. package/dist/assets/SettingsView-e7Fmxnz8.js +0 -28
  117. package/dist/assets/contextPanelEmbeddedChat-5VGWIT_J.js +0 -1
  118. package/dist/assets/de-B6t6T54h.js +0 -9
  119. package/dist/assets/es-DH9NUKge.js +0 -15
  120. package/dist/assets/fr-Do4t2KmA.js +0 -13
  121. package/dist/assets/index-B45s9aAX.css +0 -1
  122. package/dist/assets/index-CNrN5qDs.js +0 -7
  123. package/dist/assets/ja-DJT9EM80.js +0 -15
  124. package/dist/assets/ko-CfWRq2p4.js +0 -15
  125. package/dist/assets/main-B4oBRI9u.js +0 -193
  126. package/dist/assets/markdownCore-A3_L34oS.js +0 -2
  127. package/dist/assets/pt-BR-BDEzzltP.js +0 -15
  128. package/dist/assets/renderMobileApp-DA7wpIBi.js +0 -23
  129. package/dist/assets/runtimeEndpointReset-D5izT-u5.js +0 -13
  130. package/dist/assets/scheduledTasksApi-CTJdfSWc.js +0 -1
  131. package/dist/assets/uk-B6Q32nyk.js +0 -15
  132. package/dist/assets/useInlineCommentController-D7zs7-BQ.js +0 -2
  133. package/dist/assets/vendor-zumer-snapdom-Btyu_Xi2.js +0 -8
  134. package/dist/assets/zh-CN-7MGcwGaC.js +0 -15
  135. package/dist/assets/zh-TW-CFPfqxlL.js +0 -15
  136. package/server/lib/preview/proxy-runtime.js +0 -1604
  137. package/server/lib/preview/proxy-runtime.test.js +0 -528
  138. package/server/lib/quota/opencode-go-credentials.js +0 -11
  139. package/server/lib/quota/opencode-go-credentials.test.js +0 -32
  140. package/server/lib/quota/routes.test.js +0 -40
@@ -60,4 +60,4 @@ async function modelsCommand(options = {}, action = 'show') {
60
60
  process.stdout.write(formatModelsOutput(result));
61
61
  }
62
62
 
63
- export { modelsCommand, formatModelsOutput, formatDefaultLine, formatModelRef };
63
+ export { modelsCommand, formatModelsOutput };
@@ -1 +1 @@
1
- import{j as a}from"./vendor-react-BUCujlKS.js";import{I as l,a as I}from"./useInlineCommentController-D7zs7-BQ.js";function E(g){const{drafts:x,editingDraftId:d,commentText:o,onTextChange:r,selection:n,isDragging:u,fileLabel:s,newWidgetId:f,mapDraftToRange:p,onSave:m,onCancel:c,onEdit:C,onDelete:h}=g,t=[];for(const e of x){const i=p(e);if(e.id===d){t.push({afterLine:i.end,id:`edit-${e.id}`,content:a.jsx(l,{initialText:o,onTextChange:r,fileLabel:s,lineRange:i,isEditing:!0,onSave:m,onCancel:c},`edit-${e.id}`)});continue}t.push({afterLine:i.end,id:`card-${e.id}`,content:a.jsx(I,{draft:e,onEdit:()=>C(e),onDelete:()=>h(e)},`card-${e.id}`)})}if(n&&!d&&!u){const e={...n,start:Math.min(n.start,n.end),end:Math.max(n.start,n.end)};t.push({afterLine:e.end,id:f,content:a.jsx(l,{initialText:o,onTextChange:r,fileLabel:s,lineRange:e,isEditing:!1,onSave:m,onCancel:c},f)})}return t}export{E as b};
1
+ import{j as a}from"./vendor-react-BUCujlKS.js";import{I as l,a as I}from"./useInlineCommentController-CYPvYJDt.js";function E(g){const{drafts:x,editingDraftId:d,commentText:o,onTextChange:r,selection:n,isDragging:u,fileLabel:s,newWidgetId:f,mapDraftToRange:p,onSave:m,onCancel:c,onEdit:C,onDelete:h}=g,t=[];for(const e of x){const i=p(e);if(e.id===d){t.push({afterLine:i.end,id:`edit-${e.id}`,content:a.jsx(l,{initialText:o,onTextChange:r,fileLabel:s,lineRange:i,isEditing:!0,onSave:m,onCancel:c},`edit-${e.id}`)});continue}t.push({afterLine:i.end,id:`card-${e.id}`,content:a.jsx(I,{draft:e,onEdit:()=>C(e),onDelete:()=>h(e)},`card-${e.id}`)})}if(n&&!d&&!u){const e={...n,start:Math.min(n.start,n.end),end:Math.max(n.start,n.end)};t.push({afterLine:e.end,id:f,content:a.jsx(l,{initialText:o,onTextChange:r,fileLabel:s,lineRange:e,isEditing:!1,onSave:m,onCancel:c},f)})}return t}export{E as b};
@@ -1 +1 @@
1
- import{R as k,f as oe,j as s}from"./vendor-react-BUCujlKS.js";import{u as Ae}from"./vendor-tanstack-react-virtual-g05Cx3z9.js";import{f as Q,ac as ze,aW as me,aX as fe,I as M,aY as ue,g as J,B as q,Y as Ee,gv as Te,br as pe,bs as ge,bt as xe,bu as be,bv as ye,bw as ve,aU as Ie}from"./useAppFontEffects-Bbpz77To.js";import{u as Ce}from"./index-CNrN5qDs.js";const ke={"?":{code:"?",color:"var(--status-info)",description:"Untracked file"},A:{code:"A",color:"var(--status-success)",description:"New file"},D:{code:"D",color:"var(--status-error)",description:"Deleted file"},R:{code:"R",color:"var(--status-info)",description:"Renamed file"},C:{code:"C",color:"var(--status-info)",description:"Copied file"},M:{code:"M",color:"var(--status-warning)",description:"Modified file"}},Me=ke.M;function Re(p){const e=p.index?.trim(),t=p.working_dir?.trim();return e&&e!=="?"?e.charAt(0):t?t.charAt(0):e?.charAt(0)||t?.charAt(0)||"M"}function He(p){const e=Re(p);return ke[e]??Me}const $e=k.memo(function(e){const t=oe.c(58),{file:r,actionLabel:g,actionSymbol:x,onAction:m,onViewDiff:d,onRevert:l,isReverting:h,stats:I,rowPaddingClassName:f,indentPx:y,actionAtStart:A,showRevert:z}=e,v=y===void 0?0:y,o=A===void 0?!1:A,j=z===void 0?!0:z;let S;t[0]!==r?(S=He(r),t[0]=r,t[1]=S):S=t[1];const u=S,{t:E}=Q(),R=u.description,D=I?.insertions??0,w=I?.deletions??0;let V;t[2]!==m||t[3]!==d?(V=W=>{W.key===" "?(W.preventDefault(),m()):W.key==="Enter"&&(W.preventDefault(),d())},t[2]=m,t[3]=d,t[4]=V):V=t[4];const b=V;let H;t[5]!==m?(H=W=>{W.preventDefault(),W.stopPropagation(),m()},t[5]=m,t[6]=H):H=t[6];const $=H;let O;t[7]!==l?(O=W=>{W.preventDefault(),W.stopPropagation(),l()},t[7]=l,t[8]=O):O=t[8];const F=O;let P;t[9]!==g||t[10]!==x||t[11]!==$?(P=s.jsx("button",{type:"button",onClick:$,className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":g,title:g,children:x}),t[9]=g,t[10]=x,t[11]=$,t[12]=P):P=t[12];const Y=P,_=`group flex items-center gap-2 py-1.5 cursor-pointer ${f??"px-3"}`;let T;t[13]!==v?(T=v>0?{paddingLeft:`${v}px`}:void 0,t[13]=v,t[14]=T):T=t[14];const X=o?Y:null;let G;t[15]!==u.color?(G={color:u.color},t[15]=u.color,t[16]=G):G=t[16];let L;t[17]!==u.code||t[18]!==R||t[19]!==G?(L=s.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:G,title:R,"aria-label":R,children:u.code}),t[17]=u.code,t[18]=R,t[19]=G,t[20]=L):L=t[20];let B;t[21]!==r.path?(B=s.jsx(ze,{filePath:r.path,className:"h-3.5 w-3.5 shrink-0"}),t[21]=r.path,t[22]=B):B=t[22];let K;if(t[23]!==r.path){e:{const W=r.path.lastIndexOf("/");if(W===-1){let ne;t[25]===Symbol.for("react.memo_cache_sentinel")?(ne={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},t[25]=ne):ne=t[25],K=s.jsx("span",{className:"flex-1 min-w-0 truncate typography-ui-label text-foreground",style:ne,title:r.path,children:r.path});break e}const De=r.path.slice(0,W),Ve=r.path.slice(W);let te;t[26]===Symbol.for("react.memo_cache_sentinel")?(te={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},t[26]=te):te=t[26];let se;t[27]===Symbol.for("react.memo_cache_sentinel")?(se=s.jsx("span",{className:"text-muted-foreground",children:"/"}),t[27]=se):se=t[27];const re=s.jsx("span",{className:"text-foreground",children:Ve.slice(1)});let ie;t[28]!==re?(ie=s.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[se,re]}),t[28]=re,t[29]=ie):ie=t[29],K=s.jsxs("span",{className:"flex-1 min-w-0 flex items-baseline overflow-hidden",title:r.path,children:[s.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:te,children:De}),ie]})}t[23]=r.path,t[24]=K}else K=t[24];let U;t[30]===Symbol.for("react.memo_cache_sentinel")?(U={color:"var(--status-success)"},t[30]=U):U=t[30];let i;t[31]!==D?(i=s.jsxs("span",{style:U,children:["+",D]}),t[31]=D,t[32]=i):i=t[32];let n,a;t[33]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),a={color:"var(--status-error)"},t[33]=n,t[34]=a):(n=t[33],a=t[34]);let c;t[35]!==w?(c=s.jsxs("span",{style:a,children:["-",w]}),t[35]=w,t[36]=c):c=t[36];let N;t[37]!==i||t[38]!==c?(N=s.jsxs("span",{className:"shrink-0 typography-micro",children:[i,n,c]}),t[37]=i,t[38]=c,t[39]=N):N=t[39];let C;t[40]!==r.path||t[41]!==F||t[42]!==h||t[43]!==j||t[44]!==E?(C=j?s.jsxs(me,{children:[s.jsx(fe,{asChild:!0,children:s.jsx("button",{type:"button",onClick:F,disabled:h,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50","aria-label":E("gitView.changes.revertFileAria",{path:r.path}),children:h?s.jsx(M,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(M,{name:"arrow-go-back",className:"size-3.5"})})}),s.jsx(ue,{sideOffset:8,children:E("gitView.changes.revertFileTooltip")})]}):null,t[40]=r.path,t[41]=F,t[42]=h,t[43]=j,t[44]=E,t[45]=C):C=t[45];const Z=o?null:Y;let ee;return t[46]!==b||t[47]!==d||t[48]!==T||t[49]!==X||t[50]!==L||t[51]!==B||t[52]!==K||t[53]!==N||t[54]!==C||t[55]!==Z||t[56]!==_?(ee=s.jsxs("div",{className:_,role:"button",tabIndex:0,onClick:d,onKeyDown:b,style:T,children:[X,L,B,K,N,C,Z]}),t[46]=b,t[47]=d,t[48]=T,t[49]=X,t[50]=L,t[51]=B,t[52]=K,t[53]=N,t[54]=C,t[55]=Z,t[56]=_,t[57]=ee):ee=t[57],ee}),je=14,Se=p=>p.replace(/\\/g,"/").replace(/^\/+/,"").trim(),we=(p,e)=>({id:`dir:${p}`,path:p,name:e,children:new Map,directFiles:[],files:[]}),Fe=p=>{const e=we("","");for(const t of p){const r=Se(t.path);if(!r)continue;const x=r.split("/").filter(Boolean).slice(0,-1);let m=e;if(m.files.push(t),x.length>0){let d="";for(const l of x){d=d?`${d}/${l}`:l;const h=m.children.get(l);if(h){h.files.push(t),m=h;continue}const I=we(d,l);I.files.push(t),m.children.set(l,I),m=I}}m.directFiles.push(t)}return e},Pe=(p,e)=>{const t=[],r=(g,x)=>{const m=Array.from(g.children.values()).sort((l,h)=>l.path.localeCompare(h.path));for(const l of m)t.push({key:l.id,kind:"directory",depth:x,directory:l}),e.has(l.path)&&r(l,x+1);const d=[...g.directFiles].sort((l,h)=>l.path.localeCompare(h.path));for(const l of d)t.push({key:`file:${Se(l.path)}`,kind:"file",depth:x,file:l})};return r(p,0),t},Le=1e3,Ne=34,ce=30,le="pl-0 pr-2",de=(p,e)=>`${p} ${e}`,Ye=({groups:p,diffStats:e,revertingPaths:t,isRevertingAll:r=!1,headerBackgroundClassName:g="bg-sidebar",onVisiblePathsChange:x,onRevertAll:m,onRevertDirectory:d})=>{const{t:l}=Q(),h=k.useRef(null),f=Ce(i=>i.gitChangesViewMode)==="tree",y=k.useMemo(()=>p.filter(i=>i.entries.length>0),[p]),[A,z]=k.useState(new Set),[v,o]=k.useState(new Set),[j,S]=k.useState(!1),[u,E]=k.useState(null),R=k.useMemo(()=>y.map(i=>Fe(i.entries)),[y]),D=k.useMemo(()=>{const i=[];return y.forEach((n,a)=>{Array.from(R[a]?.children.values()??[]).forEach(c=>{i.push(de(n.id,c.path))})}),i},[R,y]);k.useEffect(()=>{f&&o(i=>{const n=new Set,a=new Set(D);return i.forEach(c=>{(c.slice(c.indexOf(" ")+1).includes("/")||a.has(c))&&n.add(c)}),D.forEach(c=>n.add(c)),n})},[f,D]);const w=k.useMemo(()=>{const i=[];return y.forEach((n,a)=>{if(i.push({type:"header",key:`header:${n.id}`,groupIndex:a}),!A.has(n.id)){if(f){const c=new Set;v.forEach(C=>{C.startsWith(`${n.id} `)&&c.add(C.slice(n.id.length+1))}),Pe(R[a],c).forEach(C=>{C.kind==="file"?i.push({type:"file",key:`${n.id}:${C.key}`,groupIndex:a,file:C.file,depth:C.depth}):i.push({type:"directory",key:`${n.id}:${C.key}`,groupIndex:a,directory:C.directory,depth:C.depth})});return}n.entries.forEach(c=>{i.push({type:"file",key:`${n.id}:file:${c.path}`,groupIndex:a,file:c,depth:0})})}}),m&&y.length>0&&i.push({type:"revert-all",key:"revert-all"}),i},[A,v,f,m,R,y]),V=w.length,b=V>=Le,H=Ae({count:V,enabled:b,getScrollElement:()=>h.current,estimateSize:()=>Ne,overscan:12,getItemKey:i=>w[i]?.key??i}),$=H.getVirtualItems(),O=k.useMemo(()=>{if(!b)return 0;const i=h.current?.scrollTop??0;return $.find(a=>a.end>i)?.index??0},[b,$,h]);k.useEffect(()=>{if(!x)return;const i=n=>n&&n.type==="file"?n.file.path:null;if(V===0){x([]);return}if(!b){const n=[];for(const a of w)if(a.type==="file"&&(n.push(a.file.path),n.length>=ce))break;x(n);return}x(w.slice(O,O+Math.ceil((h.current?.clientHeight??0)/Ne)+ce).map(n=>i(n)).filter(n=>!!n).slice(0,ce))},[x,V,w,b,O]);const F=k.useCallback(i=>{z(n=>{const a=new Set(n);return a.has(i)?a.delete(i):a.add(i),a})},[]),P=k.useCallback((i,n)=>{o(a=>{const c=new Set(a),N=de(i,n);return c.has(N)?c.delete(N):c.add(N),c})},[]),Y=k.useMemo(()=>{const i=new Set;return y.forEach(n=>n.entries.forEach(a=>i.add(a.path))),Array.from(i)},[y]),_=Y.length,T=u?r||u.paths.some(i=>t.has(i)):!1,X=k.useCallback(async()=>{!m||r||Y.length===0||(await m(Y),S(!1))},[Y,r,m]),G=k.useCallback(async()=>{!d||!u||T||(await d(u.paths),E(null))},[T,d,u]),L=k.useCallback((i,n)=>{const a=A.has(i.id),c=i.entries.length;return s.jsxs("div",{className:J("sticky top-0 z-10 flex items-center gap-2 py-2",g,le,!n&&"mt-1 border-t border-border/40"),children:[s.jsx("button",{type:"button",onClick:()=>i.onActionAll(i.entries.map(N=>N.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":i.actionAllLabel,title:i.actionAllLabel,children:i.actionSymbol}),s.jsxs("button",{type:"button",onClick:()=>F(i.id),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-expanded":!a,children:[s.jsx("h3",{className:"truncate typography-ui-header font-semibold text-foreground",children:i.title}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:c}),s.jsx(M,{name:"arrow-down-s",className:J("size-3.5 shrink-0 text-muted-foreground transition-transform",a&&"-rotate-90")})]})]})},[A,g,F]),B=k.useCallback((i,n,a)=>{const c=v.has(de(i.id,n.path)),N=n.files.map(Z=>Z.path),C=r||N.some(Z=>t.has(Z));return s.jsxs("div",{className:J("group flex items-center gap-2 py-1.5",le),style:{paddingLeft:`${a*je}px`},children:[s.jsxs("button",{type:"button",onClick:()=>P(i.id,n.path),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":c?l("gitView.changes.collapseDirectoryAria",{path:n.path}):l("gitView.changes.expandDirectoryAria",{path:n.path}),children:[c?s.jsx(M,{name:"folder-open-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}):s.jsx(M,{name:"folder-3-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",title:n.path,children:n.name}),s.jsx("span",{className:"ml-auto shrink-0 typography-micro text-muted-foreground",children:n.files.length})]}),i.showRevertActions!==!1&&d?s.jsx("button",{type:"button",onClick:()=>E({path:n.path,paths:N,count:N.length}),disabled:C,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50","aria-label":l("gitView.changes.revertDirectoryAria",{path:n.path}),title:l("gitView.changes.revertDirectoryTooltip"),children:C?s.jsx(M,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(M,{name:"arrow-go-back",className:"size-3.5"})}):null,s.jsx("button",{type:"button",onClick:()=>i.onActionAll(n.files.map(Z=>Z.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":l(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),title:l(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),children:i.actionSymbol})]})},[v,r,d,t,l,P]),K=k.useCallback((i,n)=>{if(i.type==="revert-all")return s.jsx("div",{className:J("flex justify-end py-2",le),children:s.jsxs(q,{variant:"ghost",size:"sm",onClick:()=>S(!0),disabled:r,className:"gap-1.5 text-[var(--status-error)] hover:bg-[var(--status-error)]/10 hover:text-[var(--status-error)]",children:[s.jsx(M,{name:"arrow-go-back",className:"size-3.5"}),l("gitView.changes.revertAll")]})});const a=y[i.groupIndex];if(!a)return null;if(i.type==="header")return L(a,n);if(i.type==="directory")return B(a,i.directory,i.depth);const c=i.file;return s.jsx($e,{file:c,actionLabel:a.getActionLabel(c.path),actionSymbol:a.actionSymbol,onAction:()=>a.onActionFile(c.path),stats:e?.[c.path],onViewDiff:()=>a.onViewDiff(c.path),onRevert:()=>a.onRevertFile(c.path),isReverting:t.has(c.path)||r,rowPaddingClassName:le,indentPx:i.depth*je,actionAtStart:!f,showRevert:a.showRevertActions!==!1})},[e,r,f,B,L,t,l,y]),U=k.useCallback(i=>{const n=w[i],a=w[i-1];return!n||!a||n.type!=="file"&&n.type!=="directory"||a.type!=="file"&&a.type!=="directory"?!1:a.groupIndex===n.groupIndex},[w]);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"relative flex h-full min-h-0 w-full flex-col overflow-hidden",children:[s.jsx(Ee,{ref:h,className:"overlay-scrollbar-target overlay-scrollbar-container min-h-0 w-full flex-1 overflow-x-hidden overflow-y-auto",children:b?s.jsx("div",{style:{height:H.getTotalSize(),position:"relative"},children:$.map(i=>{const n=w[i.index];return n?s.jsx("div",{"data-index":i.index,ref:H.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${i.start}px)`},className:J(U(i.index)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:K(n,i.index===0)},n.key):null})}):s.jsx("div",{role:"list","aria-label":l("gitView.changes.changedFilesAria"),children:w.map((i,n)=>s.jsx("div",{className:J("relative",U(n)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:K(i,n===0)},i.key))})}),s.jsx(Te,{containerRef:h,disableHorizontal:!0})]}),s.jsx(pe,{open:j,onOpenChange:i=>{!r&&!i&&S(!1)},children:s.jsxs(ge,{className:"max-w-md",children:[s.jsxs(xe,{children:[s.jsx(be,{children:l("gitView.changes.revertAllDialogTitle")}),s.jsx(ye,{children:_===1?l("gitView.changes.revertAllDescriptionSingle",{count:_}):l("gitView.changes.revertAllDescriptionPlural",{count:_})})]}),s.jsxs(ve,{children:[s.jsx(q,{variant:"outline",size:"sm",onClick:()=>S(!1),disabled:r,children:l("gitView.common.cancel")}),s.jsx(q,{variant:"destructive",size:"sm",onClick:()=>{X()},disabled:r,children:l(r?"gitView.changes.reverting":"gitView.changes.revertAll")})]})]})}),s.jsx(pe,{open:!!u,onOpenChange:i=>{!T&&!i&&E(null)},children:s.jsxs(ge,{className:"max-w-md",children:[s.jsxs(xe,{children:[s.jsx(be,{children:l("gitView.changes.revertDirectoryDialogTitle")}),s.jsx(ye,{children:u?u.count===1?l("gitView.changes.revertDirectoryDescriptionSingle",{count:u.count,path:u.path}):l("gitView.changes.revertDirectoryDescriptionPlural",{count:u.count,path:u.path}):null})]}),s.jsxs(ve,{children:[s.jsx(q,{variant:"outline",size:"sm",onClick:()=>E(null),disabled:T,children:l("gitView.common.cancel")}),s.jsx(q,{variant:"destructive",size:"sm",onClick:()=>{G()},disabled:T||!u,children:l(T?"gitView.changes.reverting":"gitView.changes.revertDirectory")})]})]})})]})},he=38,ae=200,Ge=p=>{const e=oe.c(20),{value:t,onChange:r,placeholder:g,disabled:x,hasTouchInput:m,isMobile:d}=p,l=x===void 0?!1:x,h=m===void 0?!1:m,I=d===void 0?!1:d,{t:f}=Q(),y=k.useRef(null),A=Ce(Oe);let z;e[0]===Symbol.for("react.memo_cache_sentinel")?(z=()=>{const b=y.current;if(!b)return;const H=document.activeElement===b,$=()=>{b.style.height=`${he}px`;const F=b.scrollHeight,P=Math.min(Math.max(F,he),ae);b.style.height=`${P}px`,b.style.overflowY=F>ae?"auto":"hidden",F>ae&&!H&&(b.scrollTop=b.scrollHeight)};$();const O=window.requestAnimationFrame($);return()=>{window.cancelAnimationFrame(O)}},e[0]=z):z=e[0];let v;e[1]!==t?(v=[t],e[1]=t,e[2]=v):v=e[2],k.useLayoutEffect(z,v);let o;e[3]!==r?(o=b=>r(b.target.value),e[3]=r,e[4]=o):o=e[4];let j;e[5]!==g||e[6]!==f?(j=g??f("gitView.commit.messagePlaceholder"),e[5]=g,e[6]=f,e[7]=j):j=e[7];const S=h?"on":"off",u=h?"sentences":"off",E=I||A,R=l&&"opacity-50";let D;e[8]!==R?(D=J("w-full rounded-lg border border-border/60 bg-surface-elevated px-3 py-2 typography-ui-label text-foreground placeholder:text-muted-foreground","resize-none outline-none transition-[border-color,box-shadow] duration-150","focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",R),e[8]=R,e[9]=D):D=e[9];let w;e[10]===Symbol.for("react.memo_cache_sentinel")?(w={minHeight:he,maxHeight:ae},e[10]=w):w=e[10];let V;return e[11]!==l||e[12]!==E||e[13]!==D||e[14]!==o||e[15]!==j||e[16]!==S||e[17]!==u||e[18]!==t?(V=s.jsx("textarea",{ref:y,value:t,onChange:o,placeholder:j,rows:1,disabled:l,autoCorrect:S,autoCapitalize:u,spellCheck:E,className:D,style:w}),e[11]=l,e[12]=E,e[13]=D,e[14]=o,e[15]=j,e[16]=S,e[17]=u,e[18]=t,e[19]=V):V=e[19],V};function Oe(p){return p.inputSpellcheckEnabled}const _e=p=>{const e=oe.c(30),{highlights:t,onInsert:r}=p,{t:g}=Q();if(t.length===0)return null;let x;e[0]!==t||e[1]!==r?(x=()=>{r(t)},e[0]=t,e[1]=r,e[2]=x):x=e[2];const m=x;let d;e[3]!==g?(d=g("gitView.commit.aiHighlights.title"),e[3]=g,e[4]=d):d=e[4];let l;e[5]!==d?(l=s.jsx("p",{className:"typography-micro text-muted-foreground",children:d}),e[5]=d,e[6]=l):l=e[6];let h;e[7]!==g?(h=g("gitView.commit.aiHighlights.insertAria"),e[7]=g,e[8]=h):h=e[8];let I;e[9]===Symbol.for("react.memo_cache_sentinel")?(I=s.jsx(M,{name:"arrow-down",className:"size-4"}),e[9]=I):I=e[9];let f;e[10]!==m||e[11]!==h?(f=s.jsx(fe,{asChild:!0,children:s.jsx(q,{variant:"ghost",size:"icon",className:"size-6",onClick:m,"aria-label":h,children:I})}),e[10]=m,e[11]=h,e[12]=f):f=e[12];let y;e[13]!==g?(y=g("gitView.commit.aiHighlights.insertTooltip"),e[13]=g,e[14]=y):y=e[14];let A;e[15]!==y?(A=s.jsx(ue,{sideOffset:8,children:y}),e[15]=y,e[16]=A):A=e[16];let z;e[17]!==f||e[18]!==A?(z=s.jsxs(me,{children:[f,A]}),e[17]=f,e[18]=A,e[19]=z):z=e[19];let v;e[20]!==l||e[21]!==z?(v=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l,z]}),e[20]=l,e[21]=z,e[22]=v):v=e[22];let o;e[23]!==t?(o=t.map(Be),e[23]=t,e[24]=o):o=e[24];let j;e[25]!==o?(j=s.jsx("ul",{className:"space-y-1",children:o}),e[25]=o,e[26]=j):j=e[26];let S;return e[27]!==v||e[28]!==j?(S=s.jsxs("div",{className:"space-y-2 rounded-xl border border-border/60 bg-transparent px-3 py-2",children:[v,j]}),e[27]=v,e[28]=j,e[29]=S):S=e[29],S};function Be(p,e){return s.jsx("li",{className:"typography-meta text-foreground",children:p},`${p}-${e}`)}const qe=p=>{const e=oe.c(75),{stagedCount:t,commitMessage:r,onCommitMessageChange:g,generatedHighlights:x,onInsertHighlights:m,onGenerateMessage:d,isGeneratingMessage:l,onCommit:h,onCommitAndPush:I,commitAction:f,hasPendingIndexMutation:y,gitmojiEnabled:A,onOpenGitmojiPicker:z}=p,v=y===void 0?!1:y,{t:o}=Q(),j=t>0;let S;e[0]!==f||e[1]!==r||e[2]!==v||e[3]!==j?(S=r.trim()&&j&&f===null&&!v,e[0]=f,e[1]=r,e[2]=v,e[3]=j,e[4]=S):S=e[4];const u=S,{isMobile:E,hasTouchInput:R}=Ie();let D;e[5]!==o?(D=o("gitView.commit.title"),e[5]=o,e[6]=D):D=e[6];let w;e[7]!==D?(w=s.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:D}),e[7]=D,e[8]=w):w=e[8];let V;e[9]!==j||e[10]!==o?(V=j?null:s.jsx("span",{className:"min-w-0 truncate typography-meta text-muted-foreground",children:o("gitView.commit.stageFilesHint")}),e[9]=j,e[10]=o,e[11]=V):V=e[11];let b;e[12]!==w||e[13]!==V?(b=s.jsxs("div",{className:"flex w-full items-baseline gap-2 px-0 pt-2 pb-1",children:[w,V]}),e[12]=w,e[13]=V,e[14]=b):b=e[14];let H;e[15]!==x||e[16]!==m?(H=s.jsx(_e,{highlights:x,onInsert:m}),e[15]=x,e[16]=m,e[17]=H):H=e[17];let $;e[18]!==o?($=o("gitView.commit.messagePlaceholder"),e[18]=o,e[19]=$):$=e[19];const O=f!==null;let F;e[20]!==r||e[21]!==R||e[22]!==E||e[23]!==g||e[24]!==$||e[25]!==O?(F=s.jsx(Ge,{value:r,onChange:g,placeholder:$,disabled:O,hasTouchInput:R,isMobile:E}),e[20]=r,e[21]=R,e[22]=E,e[23]=g,e[24]=$,e[25]=O,e[26]=F):F=e[26];let P;e[27]!==A||e[28]!==z||e[29]!==o?(P=A&&s.jsxs(q,{variant:"outline",size:"sm",onClick:z,className:"w-fit",type:"button",children:[s.jsx(M,{name:"emotion-happy",className:"size-4"}),o("gitView.commit.addGitmoji")]}),e[27]=A,e[28]=z,e[29]=o,e[30]=P):P=e[30];const Y=l||f!==null||v||t===0;let _;e[31]!==o?(_=o("gitView.commit.generateAria"),e[31]=o,e[32]=_):_=e[32];let T;e[33]!==l?(T=l?s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(M,{name:"ai-generate-2",className:"size-4 text-primary"}),e[33]=l,e[34]=T):T=e[34];let X;e[35]!==o?(X=o("gitView.commit.generate"),e[35]=o,e[36]=X):X=e[36];let G;e[37]!==X?(G=s.jsx("span",{className:"commit-actions__label",children:X}),e[37]=X,e[38]=G):G=e[38];let L;e[39]!==d||e[40]!==Y||e[41]!==_||e[42]!==T||e[43]!==G?(L=s.jsxs(q,{variant:"outline",size:"sm",onClick:d,disabled:Y,type:"button","aria-label":_,className:"commit-actions__btn",children:[T,G]}),e[39]=d,e[40]=Y,e[41]=_,e[42]=T,e[43]=G,e[44]=L):L=e[44];let B;e[45]===Symbol.for("react.memo_cache_sentinel")?(B=s.jsx("div",{className:"flex-1"}),e[45]=B):B=e[45];const K=!u||l;let U;e[46]!==o?(U=o("gitView.commit.commitAria"),e[46]=o,e[47]=U):U=e[47];let i;e[48]!==f||e[49]!==o?(i=f==="commit"?s.jsxs(s.Fragment,{children:[s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label",children:o("gitView.commit.committing")})]}):s.jsxs(s.Fragment,{children:[s.jsx(M,{name:"git-commit",className:"size-4"}),s.jsx("span",{className:"commit-actions__label",children:o("gitView.commit.commit")})]}),e[48]=f,e[49]=o,e[50]=i):i=e[50];let n;e[51]!==h||e[52]!==K||e[53]!==U||e[54]!==i?(n=s.jsx(q,{size:"sm",variant:"outline",onClick:h,disabled:K,className:"commit-actions__btn whitespace-nowrap","aria-label":U,children:i}),e[51]=h,e[52]=K,e[53]=U,e[54]=i,e[55]=n):n=e[55];let a;e[56]!==u||e[57]!==f||e[58]!==l||e[59]!==E||e[60]!==I||e[61]!==o?(a=E?s.jsxs(me,{children:[s.jsx(fe,{asChild:!0,children:s.jsx(q,{variant:"default",size:"sm",onClick:()=>I(),disabled:!u||l,className:"h-7 w-7 p-0","aria-label":o("gitView.commit.pushAria"),children:f==="commitAndPush"?s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(M,{name:"arrow-up",className:"size-3.5"})})}),s.jsx(ue,{side:"top",children:s.jsx("p",{children:o("gitView.commit.push")})})]}):s.jsx(q,{size:"sm",variant:"default",onClick:()=>I(),disabled:!u||l,className:"commit-actions__btn","aria-label":o("gitView.commit.pushAria"),children:f==="commitAndPush"?s.jsxs(s.Fragment,{children:[s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:o("gitView.commit.pushing")})]}):s.jsxs(s.Fragment,{children:[s.jsx(M,{name:"arrow-up",className:"size-3.5"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:o("gitView.commit.push")})]})}),e[56]=u,e[57]=f,e[58]=l,e[59]=E,e[60]=I,e[61]=o,e[62]=a):a=e[62];let c;e[63]!==L||e[64]!==n||e[65]!==a?(c=s.jsxs("div",{className:"@container/commit-actions flex items-center gap-2 min-w-0",children:[L,B,n,a]}),e[63]=L,e[64]=n,e[65]=a,e[66]=c):c=e[66];let N;e[67]!==F||e[68]!==P||e[69]!==c||e[70]!==H?(N=s.jsxs("div",{className:"flex flex-col gap-3 px-0 pt-1 pb-3",children:[H,F,P,c]}),e[67]=F,e[68]=P,e[69]=c,e[70]=H,e[71]=N):N=e[71];let C;return e[72]!==N||e[73]!==b?(C=s.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[b,N]}),e[72]=N,e[73]=b,e[74]=C):C=e[74],C};export{Ye as C,qe as a};
1
+ import{R as k,f as oe,j as s}from"./vendor-react-BUCujlKS.js";import{u as Ae}from"./vendor-tanstack-react-virtual-g05Cx3z9.js";import{f as Q,ad as ze,aX as me,aY as fe,I as M,aZ as ue,h as J,B as Z,Z as Ee,gs as Te,bs as pe,bt as ge,bu as xe,bv as be,bw as ye,bx as ve,aV as Ie}from"./useAppFontEffects-BikB6enL.js";import{u as Ce}from"./index-DRpChWux.js";const ke={"?":{code:"?",color:"var(--status-info)",description:"Untracked file"},A:{code:"A",color:"var(--status-success)",description:"New file"},D:{code:"D",color:"var(--status-error)",description:"Deleted file"},R:{code:"R",color:"var(--status-info)",description:"Renamed file"},C:{code:"C",color:"var(--status-info)",description:"Copied file"},M:{code:"M",color:"var(--status-warning)",description:"Modified file"}},Me=ke.M;function Re(p){const e=p.index?.trim(),t=p.working_dir?.trim();return e&&e!=="?"?e.charAt(0):t?t.charAt(0):e?.charAt(0)||t?.charAt(0)||"M"}function He(p){const e=Re(p);return ke[e]??Me}const $e=k.memo(function(e){const t=oe.c(58),{file:r,actionLabel:g,actionSymbol:x,onAction:m,onViewDiff:d,onRevert:l,isReverting:h,stats:I,rowPaddingClassName:f,indentPx:y,actionAtStart:A,showRevert:z}=e,v=y===void 0?0:y,o=A===void 0?!1:A,j=z===void 0?!0:z;let S;t[0]!==r?(S=He(r),t[0]=r,t[1]=S):S=t[1];const u=S,{t:E}=Q(),R=u.description,V=I?.insertions??0,w=I?.deletions??0;let D;t[2]!==m||t[3]!==d?(D=X=>{X.key===" "?(X.preventDefault(),m()):X.key==="Enter"&&(X.preventDefault(),d())},t[2]=m,t[3]=d,t[4]=D):D=t[4];const b=D;let H;t[5]!==m?(H=X=>{X.preventDefault(),X.stopPropagation(),m()},t[5]=m,t[6]=H):H=t[6];const $=H;let O;t[7]!==l?(O=X=>{X.preventDefault(),X.stopPropagation(),l()},t[7]=l,t[8]=O):O=t[8];const F=O;let P;t[9]!==g||t[10]!==x||t[11]!==$?(P=s.jsx("button",{type:"button",onClick:$,className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":g,title:g,children:x}),t[9]=g,t[10]=x,t[11]=$,t[12]=P):P=t[12];const Y=P,_=`group flex items-center gap-2 py-1.5 cursor-pointer ${f??"px-3"}`;let T;t[13]!==v?(T=v>0?{paddingLeft:`${v}px`}:void 0,t[13]=v,t[14]=T):T=t[14];const W=o?Y:null;let G;t[15]!==u.color?(G={color:u.color},t[15]=u.color,t[16]=G):G=t[16];let L;t[17]!==u.code||t[18]!==R||t[19]!==G?(L=s.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:G,title:R,"aria-label":R,children:u.code}),t[17]=u.code,t[18]=R,t[19]=G,t[20]=L):L=t[20];let B;t[21]!==r.path?(B=s.jsx(ze,{filePath:r.path,className:"h-3.5 w-3.5 shrink-0"}),t[21]=r.path,t[22]=B):B=t[22];let K;if(t[23]!==r.path){e:{const X=r.path.lastIndexOf("/");if(X===-1){let ne;t[25]===Symbol.for("react.memo_cache_sentinel")?(ne={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},t[25]=ne):ne=t[25],K=s.jsx("span",{className:"flex-1 min-w-0 truncate typography-ui-label text-foreground",style:ne,title:r.path,children:r.path});break e}const Ve=r.path.slice(0,X),De=r.path.slice(X);let te;t[26]===Symbol.for("react.memo_cache_sentinel")?(te={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},t[26]=te):te=t[26];let se;t[27]===Symbol.for("react.memo_cache_sentinel")?(se=s.jsx("span",{className:"text-muted-foreground",children:"/"}),t[27]=se):se=t[27];const re=s.jsx("span",{className:"text-foreground",children:De.slice(1)});let ie;t[28]!==re?(ie=s.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[se,re]}),t[28]=re,t[29]=ie):ie=t[29],K=s.jsxs("span",{className:"flex-1 min-w-0 flex items-baseline overflow-hidden",title:r.path,children:[s.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:te,children:Ve}),ie]})}t[23]=r.path,t[24]=K}else K=t[24];let U;t[30]===Symbol.for("react.memo_cache_sentinel")?(U={color:"var(--status-success)"},t[30]=U):U=t[30];let i;t[31]!==V?(i=s.jsxs("span",{style:U,children:["+",V]}),t[31]=V,t[32]=i):i=t[32];let n,a;t[33]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),a={color:"var(--status-error)"},t[33]=n,t[34]=a):(n=t[33],a=t[34]);let c;t[35]!==w?(c=s.jsxs("span",{style:a,children:["-",w]}),t[35]=w,t[36]=c):c=t[36];let N;t[37]!==i||t[38]!==c?(N=s.jsxs("span",{className:"shrink-0 typography-micro",children:[i,n,c]}),t[37]=i,t[38]=c,t[39]=N):N=t[39];let C;t[40]!==r.path||t[41]!==F||t[42]!==h||t[43]!==j||t[44]!==E?(C=j?s.jsxs(me,{children:[s.jsx(fe,{asChild:!0,children:s.jsx("button",{type:"button",onClick:F,disabled:h,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50","aria-label":E("gitView.changes.revertFileAria",{path:r.path}),children:h?s.jsx(M,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(M,{name:"arrow-go-back",className:"size-3.5"})})}),s.jsx(ue,{sideOffset:8,children:E("gitView.changes.revertFileTooltip")})]}):null,t[40]=r.path,t[41]=F,t[42]=h,t[43]=j,t[44]=E,t[45]=C):C=t[45];const q=o?null:Y;let ee;return t[46]!==b||t[47]!==d||t[48]!==T||t[49]!==W||t[50]!==L||t[51]!==B||t[52]!==K||t[53]!==N||t[54]!==C||t[55]!==q||t[56]!==_?(ee=s.jsxs("div",{className:_,role:"button",tabIndex:0,onClick:d,onKeyDown:b,style:T,children:[W,L,B,K,N,C,q]}),t[46]=b,t[47]=d,t[48]=T,t[49]=W,t[50]=L,t[51]=B,t[52]=K,t[53]=N,t[54]=C,t[55]=q,t[56]=_,t[57]=ee):ee=t[57],ee}),je=14,Se=p=>p.replace(/\\/g,"/").replace(/^\/+/,"").trim(),we=(p,e)=>({id:`dir:${p}`,path:p,name:e,children:new Map,directFiles:[],files:[]}),Fe=p=>{const e=we("","");for(const t of p){const r=Se(t.path);if(!r)continue;const x=r.split("/").filter(Boolean).slice(0,-1);let m=e;if(m.files.push(t),x.length>0){let d="";for(const l of x){d=d?`${d}/${l}`:l;const h=m.children.get(l);if(h){h.files.push(t),m=h;continue}const I=we(d,l);I.files.push(t),m.children.set(l,I),m=I}}m.directFiles.push(t)}return e},Pe=(p,e)=>{const t=[],r=(g,x)=>{const m=Array.from(g.children.values()).sort((l,h)=>l.path.localeCompare(h.path));for(const l of m)t.push({key:l.id,kind:"directory",depth:x,directory:l}),e.has(l.path)&&r(l,x+1);const d=[...g.directFiles].sort((l,h)=>l.path.localeCompare(h.path));for(const l of d)t.push({key:`file:${Se(l.path)}`,kind:"file",depth:x,file:l})};return r(p,0),t},Le=1e3,Ne=34,ce=30,le="pl-0 pr-2",de=(p,e)=>`${p} ${e}`,Ye=({groups:p,diffStats:e,revertingPaths:t,isRevertingAll:r=!1,headerBackgroundClassName:g="bg-sidebar",onVisiblePathsChange:x,onRevertAll:m,onRevertDirectory:d})=>{const{t:l}=Q(),h=k.useRef(null),f=Ce(i=>i.gitChangesViewMode)==="tree",y=k.useMemo(()=>p.filter(i=>i.entries.length>0),[p]),[A,z]=k.useState(new Set),[v,o]=k.useState(new Set),[j,S]=k.useState(!1),[u,E]=k.useState(null),R=k.useMemo(()=>y.map(i=>Fe(i.entries)),[y]),V=k.useMemo(()=>{const i=[];return y.forEach((n,a)=>{Array.from(R[a]?.children.values()??[]).forEach(c=>{i.push(de(n.id,c.path))})}),i},[R,y]);k.useEffect(()=>{f&&o(i=>{const n=new Set,a=new Set(V);return i.forEach(c=>{(c.slice(c.indexOf(" ")+1).includes("/")||a.has(c))&&n.add(c)}),V.forEach(c=>n.add(c)),n})},[f,V]);const w=k.useMemo(()=>{const i=[];return y.forEach((n,a)=>{if(i.push({type:"header",key:`header:${n.id}`,groupIndex:a}),!A.has(n.id)){if(f){const c=new Set;v.forEach(C=>{C.startsWith(`${n.id} `)&&c.add(C.slice(n.id.length+1))}),Pe(R[a],c).forEach(C=>{C.kind==="file"?i.push({type:"file",key:`${n.id}:${C.key}`,groupIndex:a,file:C.file,depth:C.depth}):i.push({type:"directory",key:`${n.id}:${C.key}`,groupIndex:a,directory:C.directory,depth:C.depth})});return}n.entries.forEach(c=>{i.push({type:"file",key:`${n.id}:file:${c.path}`,groupIndex:a,file:c,depth:0})})}}),m&&y.length>0&&i.push({type:"revert-all",key:"revert-all"}),i},[A,v,f,m,R,y]),D=w.length,b=D>=Le,H=Ae({count:D,enabled:b,getScrollElement:()=>h.current,estimateSize:()=>Ne,overscan:12,getItemKey:i=>w[i]?.key??i}),$=H.getVirtualItems(),O=k.useMemo(()=>{if(!b)return 0;const i=h.current?.scrollTop??0;return $.find(a=>a.end>i)?.index??0},[b,$,h]);k.useEffect(()=>{if(!x)return;const i=n=>n&&n.type==="file"?n.file.path:null;if(D===0){x([]);return}if(!b){const n=[];for(const a of w)if(a.type==="file"&&(n.push(a.file.path),n.length>=ce))break;x(n);return}x(w.slice(O,O+Math.ceil((h.current?.clientHeight??0)/Ne)+ce).map(n=>i(n)).filter(n=>!!n).slice(0,ce))},[x,D,w,b,O]);const F=k.useCallback(i=>{z(n=>{const a=new Set(n);return a.has(i)?a.delete(i):a.add(i),a})},[]),P=k.useCallback((i,n)=>{o(a=>{const c=new Set(a),N=de(i,n);return c.has(N)?c.delete(N):c.add(N),c})},[]),Y=k.useMemo(()=>{const i=new Set;return y.forEach(n=>n.entries.forEach(a=>i.add(a.path))),Array.from(i)},[y]),_=Y.length,T=u?r||u.paths.some(i=>t.has(i)):!1,W=k.useCallback(async()=>{!m||r||Y.length===0||(await m(Y),S(!1))},[Y,r,m]),G=k.useCallback(async()=>{!d||!u||T||(await d(u.paths),E(null))},[T,d,u]),L=k.useCallback((i,n)=>{const a=A.has(i.id),c=i.entries.length;return s.jsxs("div",{className:J("sticky top-0 z-10 flex items-center gap-2 py-2",g,le,!n&&"mt-1 border-t border-border/40"),children:[s.jsx("button",{type:"button",onClick:()=>i.onActionAll(i.entries.map(N=>N.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":i.actionAllLabel,title:i.actionAllLabel,children:i.actionSymbol}),s.jsxs("button",{type:"button",onClick:()=>F(i.id),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-expanded":!a,children:[s.jsx("h3",{className:"truncate typography-ui-header font-semibold text-foreground",children:i.title}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:c}),s.jsx(M,{name:"arrow-down-s",className:J("size-3.5 shrink-0 text-muted-foreground transition-transform",a&&"-rotate-90")})]})]})},[A,g,F]),B=k.useCallback((i,n,a)=>{const c=v.has(de(i.id,n.path)),N=n.files.map(q=>q.path),C=r||N.some(q=>t.has(q));return s.jsxs("div",{className:J("group flex items-center gap-2 py-1.5",le),style:{paddingLeft:`${a*je}px`},children:[s.jsxs("button",{type:"button",onClick:()=>P(i.id,n.path),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":c?l("gitView.changes.collapseDirectoryAria",{path:n.path}):l("gitView.changes.expandDirectoryAria",{path:n.path}),children:[c?s.jsx(M,{name:"folder-open-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}):s.jsx(M,{name:"folder-3-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",title:n.path,children:n.name}),s.jsx("span",{className:"ml-auto shrink-0 typography-micro text-muted-foreground",children:n.files.length})]}),i.showRevertActions!==!1&&d?s.jsx("button",{type:"button",onClick:()=>E({path:n.path,paths:N,count:N.length}),disabled:C,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50","aria-label":l("gitView.changes.revertDirectoryAria",{path:n.path}),title:l("gitView.changes.revertDirectoryTooltip"),children:C?s.jsx(M,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(M,{name:"arrow-go-back",className:"size-3.5"})}):null,s.jsx("button",{type:"button",onClick:()=>i.onActionAll(n.files.map(q=>q.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":l(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),title:l(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),children:i.actionSymbol})]})},[v,r,d,t,l,P]),K=k.useCallback((i,n)=>{if(i.type==="revert-all")return s.jsx("div",{className:J("flex justify-end py-2",le),children:s.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>S(!0),disabled:r,className:"gap-1.5 text-[var(--status-error)] hover:bg-[var(--status-error)]/10 hover:text-[var(--status-error)]",children:[s.jsx(M,{name:"arrow-go-back",className:"size-3.5"}),l("gitView.changes.revertAll")]})});const a=y[i.groupIndex];if(!a)return null;if(i.type==="header")return L(a,n);if(i.type==="directory")return B(a,i.directory,i.depth);const c=i.file;return s.jsx($e,{file:c,actionLabel:a.getActionLabel(c.path),actionSymbol:a.actionSymbol,onAction:()=>a.onActionFile(c.path),stats:e?.[c.path],onViewDiff:()=>a.onViewDiff(c.path),onRevert:()=>a.onRevertFile(c.path),isReverting:t.has(c.path)||r,rowPaddingClassName:le,indentPx:i.depth*je,actionAtStart:!f,showRevert:a.showRevertActions!==!1})},[e,r,f,B,L,t,l,y]),U=k.useCallback(i=>{const n=w[i],a=w[i-1];return!n||!a||n.type!=="file"&&n.type!=="directory"||a.type!=="file"&&a.type!=="directory"?!1:a.groupIndex===n.groupIndex},[w]);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"relative flex h-full min-h-0 w-full flex-col overflow-hidden",children:[s.jsx(Ee,{ref:h,className:"overlay-scrollbar-target overlay-scrollbar-container min-h-0 w-full flex-1 overflow-x-hidden overflow-y-auto",children:b?s.jsx("div",{style:{height:H.getTotalSize(),position:"relative"},children:$.map(i=>{const n=w[i.index];return n?s.jsx("div",{"data-index":i.index,ref:H.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${i.start}px)`},className:J(U(i.index)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:K(n,i.index===0)},n.key):null})}):s.jsx("div",{role:"list","aria-label":l("gitView.changes.changedFilesAria"),children:w.map((i,n)=>s.jsx("div",{className:J("relative",U(n)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:K(i,n===0)},i.key))})}),s.jsx(Te,{containerRef:h,disableHorizontal:!0})]}),s.jsx(pe,{open:j,onOpenChange:i=>{!r&&!i&&S(!1)},children:s.jsxs(ge,{className:"max-w-md",children:[s.jsxs(xe,{children:[s.jsx(be,{children:l("gitView.changes.revertAllDialogTitle")}),s.jsx(ye,{children:_===1?l("gitView.changes.revertAllDescriptionSingle",{count:_}):l("gitView.changes.revertAllDescriptionPlural",{count:_})})]}),s.jsxs(ve,{children:[s.jsx(Z,{variant:"outline",size:"sm",onClick:()=>S(!1),disabled:r,children:l("gitView.common.cancel")}),s.jsx(Z,{variant:"destructive",size:"sm",onClick:()=>{W()},disabled:r,children:l(r?"gitView.changes.reverting":"gitView.changes.revertAll")})]})]})}),s.jsx(pe,{open:!!u,onOpenChange:i=>{!T&&!i&&E(null)},children:s.jsxs(ge,{className:"max-w-md",children:[s.jsxs(xe,{children:[s.jsx(be,{children:l("gitView.changes.revertDirectoryDialogTitle")}),s.jsx(ye,{children:u?u.count===1?l("gitView.changes.revertDirectoryDescriptionSingle",{count:u.count,path:u.path}):l("gitView.changes.revertDirectoryDescriptionPlural",{count:u.count,path:u.path}):null})]}),s.jsxs(ve,{children:[s.jsx(Z,{variant:"outline",size:"sm",onClick:()=>E(null),disabled:T,children:l("gitView.common.cancel")}),s.jsx(Z,{variant:"destructive",size:"sm",onClick:()=>{G()},disabled:T||!u,children:l(T?"gitView.changes.reverting":"gitView.changes.revertDirectory")})]})]})})]})},he=38,ae=200,Ge=p=>{const e=oe.c(20),{value:t,onChange:r,placeholder:g,disabled:x,hasTouchInput:m,isMobile:d}=p,l=x===void 0?!1:x,h=m===void 0?!1:m,I=d===void 0?!1:d,{t:f}=Q(),y=k.useRef(null),A=Ce(Oe);let z;e[0]===Symbol.for("react.memo_cache_sentinel")?(z=()=>{const b=y.current;if(!b)return;const H=document.activeElement===b,$=()=>{b.style.height=`${he}px`;const F=b.scrollHeight,P=Math.min(Math.max(F,he),ae);b.style.height=`${P}px`,b.style.overflowY=F>ae?"auto":"hidden",F>ae&&!H&&(b.scrollTop=b.scrollHeight)};$();const O=window.requestAnimationFrame($);return()=>{window.cancelAnimationFrame(O)}},e[0]=z):z=e[0];let v;e[1]!==t?(v=[t],e[1]=t,e[2]=v):v=e[2],k.useLayoutEffect(z,v);let o;e[3]!==r?(o=b=>r(b.target.value),e[3]=r,e[4]=o):o=e[4];let j;e[5]!==g||e[6]!==f?(j=g??f("gitView.commit.messagePlaceholder"),e[5]=g,e[6]=f,e[7]=j):j=e[7];const S=h?"on":"off",u=h?"sentences":"off",E=I||A,R=l&&"opacity-50";let V;e[8]!==R?(V=J("w-full rounded-lg border border-border/60 bg-surface-elevated px-3 py-2 typography-ui-label text-foreground placeholder:text-muted-foreground","resize-none outline-none transition-[border-color,box-shadow] duration-150","focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",R),e[8]=R,e[9]=V):V=e[9];let w;e[10]===Symbol.for("react.memo_cache_sentinel")?(w={minHeight:he,maxHeight:ae},e[10]=w):w=e[10];let D;return e[11]!==l||e[12]!==E||e[13]!==V||e[14]!==o||e[15]!==j||e[16]!==S||e[17]!==u||e[18]!==t?(D=s.jsx("textarea",{ref:y,value:t,onChange:o,placeholder:j,rows:1,disabled:l,autoCorrect:S,autoCapitalize:u,spellCheck:E,className:V,style:w}),e[11]=l,e[12]=E,e[13]=V,e[14]=o,e[15]=j,e[16]=S,e[17]=u,e[18]=t,e[19]=D):D=e[19],D};function Oe(p){return p.inputSpellcheckEnabled}const _e=p=>{const e=oe.c(30),{highlights:t,onInsert:r}=p,{t:g}=Q();if(t.length===0)return null;let x;e[0]!==t||e[1]!==r?(x=()=>{r(t)},e[0]=t,e[1]=r,e[2]=x):x=e[2];const m=x;let d;e[3]!==g?(d=g("gitView.commit.aiHighlights.title"),e[3]=g,e[4]=d):d=e[4];let l;e[5]!==d?(l=s.jsx("p",{className:"typography-micro text-muted-foreground",children:d}),e[5]=d,e[6]=l):l=e[6];let h;e[7]!==g?(h=g("gitView.commit.aiHighlights.insertAria"),e[7]=g,e[8]=h):h=e[8];let I;e[9]===Symbol.for("react.memo_cache_sentinel")?(I=s.jsx(M,{name:"arrow-down",className:"size-4"}),e[9]=I):I=e[9];let f;e[10]!==m||e[11]!==h?(f=s.jsx(fe,{asChild:!0,children:s.jsx(Z,{variant:"ghost",size:"icon",className:"size-6",onClick:m,"aria-label":h,children:I})}),e[10]=m,e[11]=h,e[12]=f):f=e[12];let y;e[13]!==g?(y=g("gitView.commit.aiHighlights.insertTooltip"),e[13]=g,e[14]=y):y=e[14];let A;e[15]!==y?(A=s.jsx(ue,{sideOffset:8,children:y}),e[15]=y,e[16]=A):A=e[16];let z;e[17]!==f||e[18]!==A?(z=s.jsxs(me,{children:[f,A]}),e[17]=f,e[18]=A,e[19]=z):z=e[19];let v;e[20]!==l||e[21]!==z?(v=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l,z]}),e[20]=l,e[21]=z,e[22]=v):v=e[22];let o;e[23]!==t?(o=t.map(Be),e[23]=t,e[24]=o):o=e[24];let j;e[25]!==o?(j=s.jsx("ul",{className:"space-y-1",children:o}),e[25]=o,e[26]=j):j=e[26];let S;return e[27]!==v||e[28]!==j?(S=s.jsxs("div",{className:"space-y-2 rounded-xl border border-border/60 bg-transparent px-3 py-2",children:[v,j]}),e[27]=v,e[28]=j,e[29]=S):S=e[29],S};function Be(p,e){return s.jsx("li",{className:"typography-meta text-foreground",children:p},`${p}-${e}`)}const Ze=p=>{const e=oe.c(75),{stagedCount:t,commitMessage:r,onCommitMessageChange:g,generatedHighlights:x,onInsertHighlights:m,onGenerateMessage:d,isGeneratingMessage:l,onCommit:h,onCommitAndPush:I,commitAction:f,hasPendingIndexMutation:y,gitmojiEnabled:A,onOpenGitmojiPicker:z}=p,v=y===void 0?!1:y,{t:o}=Q(),j=t>0;let S;e[0]!==f||e[1]!==r||e[2]!==v||e[3]!==j?(S=r.trim()&&j&&f===null&&!v,e[0]=f,e[1]=r,e[2]=v,e[3]=j,e[4]=S):S=e[4];const u=S,{isMobile:E,hasTouchInput:R}=Ie();let V;e[5]!==o?(V=o("gitView.commit.title"),e[5]=o,e[6]=V):V=e[6];let w;e[7]!==V?(w=s.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:V}),e[7]=V,e[8]=w):w=e[8];let D;e[9]!==j||e[10]!==o?(D=j?null:s.jsx("span",{className:"min-w-0 truncate typography-meta text-muted-foreground",children:o("gitView.commit.stageFilesHint")}),e[9]=j,e[10]=o,e[11]=D):D=e[11];let b;e[12]!==w||e[13]!==D?(b=s.jsxs("div",{className:"flex w-full items-baseline gap-2 px-0 pt-2 pb-1",children:[w,D]}),e[12]=w,e[13]=D,e[14]=b):b=e[14];let H;e[15]!==x||e[16]!==m?(H=s.jsx(_e,{highlights:x,onInsert:m}),e[15]=x,e[16]=m,e[17]=H):H=e[17];let $;e[18]!==o?($=o("gitView.commit.messagePlaceholder"),e[18]=o,e[19]=$):$=e[19];const O=f!==null;let F;e[20]!==r||e[21]!==R||e[22]!==E||e[23]!==g||e[24]!==$||e[25]!==O?(F=s.jsx(Ge,{value:r,onChange:g,placeholder:$,disabled:O,hasTouchInput:R,isMobile:E}),e[20]=r,e[21]=R,e[22]=E,e[23]=g,e[24]=$,e[25]=O,e[26]=F):F=e[26];let P;e[27]!==A||e[28]!==z||e[29]!==o?(P=A&&s.jsxs(Z,{variant:"outline",size:"sm",onClick:z,className:"w-fit",type:"button",children:[s.jsx(M,{name:"emotion-happy",className:"size-4"}),o("gitView.commit.addGitmoji")]}),e[27]=A,e[28]=z,e[29]=o,e[30]=P):P=e[30];const Y=l||f!==null||v||t===0;let _;e[31]!==o?(_=o("gitView.commit.generateAria"),e[31]=o,e[32]=_):_=e[32];let T;e[33]!==l?(T=l?s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(M,{name:"ai-generate-2",className:"size-4 text-primary"}),e[33]=l,e[34]=T):T=e[34];let W;e[35]!==o?(W=o("gitView.commit.generate"),e[35]=o,e[36]=W):W=e[36];let G;e[37]!==W?(G=s.jsx("span",{className:"commit-actions__label",children:W}),e[37]=W,e[38]=G):G=e[38];let L;e[39]!==d||e[40]!==Y||e[41]!==_||e[42]!==T||e[43]!==G?(L=s.jsxs(Z,{variant:"outline",size:"sm",onClick:d,disabled:Y,type:"button","aria-label":_,className:"commit-actions__btn",children:[T,G]}),e[39]=d,e[40]=Y,e[41]=_,e[42]=T,e[43]=G,e[44]=L):L=e[44];let B;e[45]===Symbol.for("react.memo_cache_sentinel")?(B=s.jsx("div",{className:"flex-1"}),e[45]=B):B=e[45];const K=!u||l;let U;e[46]!==o?(U=o("gitView.commit.commitAria"),e[46]=o,e[47]=U):U=e[47];let i;e[48]!==f||e[49]!==o?(i=f==="commit"?s.jsxs(s.Fragment,{children:[s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label",children:o("gitView.commit.committing")})]}):s.jsxs(s.Fragment,{children:[s.jsx(M,{name:"git-commit",className:"size-4"}),s.jsx("span",{className:"commit-actions__label",children:o("gitView.commit.commit")})]}),e[48]=f,e[49]=o,e[50]=i):i=e[50];let n;e[51]!==h||e[52]!==K||e[53]!==U||e[54]!==i?(n=s.jsx(Z,{size:"sm",variant:"outline",onClick:h,disabled:K,className:"commit-actions__btn whitespace-nowrap","aria-label":U,children:i}),e[51]=h,e[52]=K,e[53]=U,e[54]=i,e[55]=n):n=e[55];let a;e[56]!==u||e[57]!==f||e[58]!==l||e[59]!==E||e[60]!==I||e[61]!==o?(a=E?s.jsxs(me,{children:[s.jsx(fe,{asChild:!0,children:s.jsx(Z,{variant:"default",size:"sm",onClick:()=>I(),disabled:!u||l,className:"h-7 w-7 p-0","aria-label":o("gitView.commit.pushAria"),children:f==="commitAndPush"?s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(M,{name:"arrow-up",className:"size-3.5"})})}),s.jsx(ue,{side:"top",children:s.jsx("p",{children:o("gitView.commit.push")})})]}):s.jsx(Z,{size:"sm",variant:"default",onClick:()=>I(),disabled:!u||l,className:"commit-actions__btn","aria-label":o("gitView.commit.pushAria"),children:f==="commitAndPush"?s.jsxs(s.Fragment,{children:[s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:o("gitView.commit.pushing")})]}):s.jsxs(s.Fragment,{children:[s.jsx(M,{name:"arrow-up",className:"size-3.5"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:o("gitView.commit.push")})]})}),e[56]=u,e[57]=f,e[58]=l,e[59]=E,e[60]=I,e[61]=o,e[62]=a):a=e[62];let c;e[63]!==L||e[64]!==n||e[65]!==a?(c=s.jsxs("div",{className:"@container/commit-actions flex items-center gap-2 min-w-0",children:[L,B,n,a]}),e[63]=L,e[64]=n,e[65]=a,e[66]=c):c=e[66];let N;e[67]!==F||e[68]!==P||e[69]!==c||e[70]!==H?(N=s.jsxs("div",{className:"flex flex-col gap-3 px-0 pt-1 pb-3",children:[H,F,P,c]}),e[67]=F,e[68]=P,e[69]=c,e[70]=H,e[71]=N):N=e[71];let C;return e[72]!==N||e[73]!==b?(C=s.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[b,N]}),e[72]=N,e[73]=b,e[74]=C):C=e[74],C};export{Ye as C,Ze as a};
@@ -1 +1 @@
1
- import{R as e,j as h}from"./vendor-react-BUCujlKS.js";import{D as E}from"./vendor-react-drawio-Ct3Q0DsD.js";import{g as x}from"./useAppFontEffects-Bbpz77To.js";const D='<mxfile><diagram id="new" name="Page-1"><mxGraphModel dx="0" dy="0" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0"><root><mxCell id="0"/><mxCell id="1" parent="0"/></root></mxGraphModel></diagram></mxfile>';function g(){if(typeof document>"u")return!1;const o=document.documentElement.getAttribute("data-theme");return o==="dark"||!o&&window.matchMedia("(prefers-color-scheme: dark)").matches}const X=e.forwardRef(function({xml:t,readOnly:a,className:R,onChange:c},v){const s=e.useRef(t),i=e.useRef(null),m=e.useRef(!1),[n,k]=e.useState(g),u=e.useRef(t),d=e.useRef(t);d.current!==t&&(d.current=t,u.current=t,s.current=t);const f=e.useRef(n);f.current!==n&&(f.current=n,u.current=s.current);const l=e.useRef(null);e.useEffect(()=>{const r=()=>k(g());r();const p=new MutationObserver(r);return p.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>p.disconnect()},[]),e.useEffect(()=>{const r=setTimeout(()=>{l.current?.querySelector(".diagrams-iframe")?.focus()},600);return()=>clearTimeout(r)},[]),e.useImperativeHandle(v,()=>({getXml:()=>s.current}));const b=e.useCallback(()=>{!t&&!m.current&&(m.current=!0,setTimeout(()=>{i.current?.template({})},500))},[t]),w=e.useCallback(r=>{s.current=r.xml,c?.(r.xml)},[c]);return h.jsx("div",{ref:l,className:x("h-full w-full",R),children:h.jsx(E,{ref:i,xml:u.current||D,autosave:!0,urlParameters:{ui:a?"simple":n?"dark":"kennedy",spin:!0,libraries:!a,chrome:a,nav:a,layers:a,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:b,onAutoSave:w},n?"dark":"light")})});export{X as D};
1
+ import{R as e,j as h}from"./vendor-react-BUCujlKS.js";import{D as E}from"./vendor-react-drawio-Ct3Q0DsD.js";import{h as x}from"./useAppFontEffects-BikB6enL.js";const D='<mxfile><diagram id="new" name="Page-1"><mxGraphModel dx="0" dy="0" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0"><root><mxCell id="0"/><mxCell id="1" parent="0"/></root></mxGraphModel></diagram></mxfile>';function g(){if(typeof document>"u")return!1;const o=document.documentElement.getAttribute("data-theme");return o==="dark"||!o&&window.matchMedia("(prefers-color-scheme: dark)").matches}const X=e.forwardRef(function({xml:t,readOnly:a,className:R,onChange:c},v){const s=e.useRef(t),i=e.useRef(null),m=e.useRef(!1),[n,k]=e.useState(g),u=e.useRef(t),d=e.useRef(t);d.current!==t&&(d.current=t,u.current=t,s.current=t);const f=e.useRef(n);f.current!==n&&(f.current=n,u.current=s.current);const l=e.useRef(null);e.useEffect(()=>{const r=()=>k(g());r();const p=new MutationObserver(r);return p.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>p.disconnect()},[]),e.useEffect(()=>{const r=setTimeout(()=>{l.current?.querySelector(".diagrams-iframe")?.focus()},600);return()=>clearTimeout(r)},[]),e.useImperativeHandle(v,()=>({getXml:()=>s.current}));const b=e.useCallback(()=>{!t&&!m.current&&(m.current=!0,setTimeout(()=>{i.current?.template({})},500))},[t]),w=e.useCallback(r=>{s.current=r.xml,c?.(r.xml)},[c]);return h.jsx("div",{ref:l,className:x("h-full w-full",R),children:h.jsx(E,{ref:i,xml:u.current||D,autosave:!0,urlParameters:{ui:a?"simple":n?"dark":"kennedy",spin:!0,libraries:!a,chrome:a,nav:a,layers:a,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:b,onAutoSave:w},n?"dark":"light")})});export{X as D};
@@ -1 +1 @@
1
- import{R as r,j as i}from"./vendor-react-BUCujlKS.js";import{u as n}from"./index-CNrN5qDs.js";import{f as j,U as b,I as m}from"./useAppFontEffects-Bbpz77To.js";import{D as y}from"./DiagramEditor-C7nUw7p3.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-D_V6hAcE.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-DKpLs02S.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./contextPanelEmbeddedChat-5VGWIT_J.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-DUOssd4j.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-CNWM3Q8V.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-DSzLbZiS.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Bbw3D7r0.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-BjbBRsUA.js";import"./vendor-codemirror-lang-json-ryCw7nab.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-VgNqFSH-.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-B3Qe3OpS.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-FGQydhTc.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-Dzt9rWZZ.js";import"./vendor-codemirror-lang-python-N414WYK-.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-ARAOgp1x.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CRSgBxjL.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-react-drawio-Ct3Q0DsD.js";function Wi(){const{t:s}=j(),{files:o}=b(),[e,g]=r.useState(null),[p,a]=r.useState(""),[x,l]=r.useState(!0),c=r.useRef(null),u=n(t=>t.pendingDiagramFile),f=r.useCallback(async t=>{l(!0),g(t);try{const d=await o?.readFile?.(t);d&&a(d.content)}catch{a("")}finally{l(!1)}},[o]);r.useEffect(()=>{if(!u)return;const t=n.getState().consumePendingDiagramFile();t&&f(t)},[f,u]);const h=r.useCallback(async()=>{const t=c.current?.getXml();e&&o?.writeFile&&t&&t!==p&&(await o.writeFile(e,t),a(t))},[e,o,p]),v=e?e.split("/").pop()||e:"";return e?x?i.jsx("div",{className:"flex h-full items-center justify-center p-3",children:i.jsx(m,{name:"loader-4",className:"size-4 animate-spin"})}):i.jsxs("div",{className:"flex h-full flex-col",children:[i.jsxs("div",{className:"flex items-center gap-2 border-b border-border/30 px-3 py-1.5",children:[i.jsx(m,{name:"file",className:"size-4 shrink-0 text-muted-foreground"}),i.jsx("span",{className:"typography-ui text-muted-foreground truncate flex-1",children:v}),i.jsx("button",{type:"button",onClick:()=>{h()},className:"size-6 flex items-center justify-center rounded-md text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",title:s("filesView.diagram.saveDiagram"),children:i.jsx(m,{name:"save-3",className:"size-4"})}),i.jsx("button",{type:"button",onClick:()=>n.getState().setActiveMainTab("chat"),className:"size-6 flex items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",title:s("filesView.diagram.closeDiagramView"),children:i.jsx(m,{name:"close",className:"size-4"})})]}),i.jsx("div",{className:"flex-1 min-h-0",children:i.jsx(y,{ref:c,xml:p,className:"h-full"})})]}):i.jsx("div",{className:"flex h-full items-center justify-center p-3",children:i.jsx("div",{className:"typography-ui text-muted-foreground",children:s("filesView.editor.pickFileFromTree")})})}export{Wi as DiagramView};
1
+ import{R as r,j as i}from"./vendor-react-BUCujlKS.js";import{u as n}from"./index-DRpChWux.js";import{f as j,V as b,I as m}from"./useAppFontEffects-BikB6enL.js";import{D as y}from"./DiagramEditor-jnG3Hbxg.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-D_V6hAcE.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-DKpLs02S.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./contextPanelEmbeddedChat-B-bSg3P5.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-DUOssd4j.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-CNWM3Q8V.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-DSzLbZiS.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Bbw3D7r0.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-BjbBRsUA.js";import"./vendor-codemirror-lang-json-ryCw7nab.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-VgNqFSH-.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-B3Qe3OpS.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-FGQydhTc.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-CLHw8NWn.js";import"./vendor-codemirror-lang-python-N414WYK-.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-ARAOgp1x.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CRSgBxjL.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-react-drawio-Ct3Q0DsD.js";function Wi(){const{t:s}=j(),{files:o}=b(),[e,g]=r.useState(null),[p,a]=r.useState(""),[x,l]=r.useState(!0),c=r.useRef(null),u=n(t=>t.pendingDiagramFile),f=r.useCallback(async t=>{l(!0),g(t);try{const d=await o?.readFile?.(t);d&&a(d.content)}catch{a("")}finally{l(!1)}},[o]);r.useEffect(()=>{if(!u)return;const t=n.getState().consumePendingDiagramFile();t&&f(t)},[f,u]);const h=r.useCallback(async()=>{const t=c.current?.getXml();e&&o?.writeFile&&t&&t!==p&&(await o.writeFile(e,t),a(t))},[e,o,p]),v=e?e.split("/").pop()||e:"";return e?x?i.jsx("div",{className:"flex h-full items-center justify-center p-3",children:i.jsx(m,{name:"loader-4",className:"size-4 animate-spin"})}):i.jsxs("div",{className:"flex h-full flex-col",children:[i.jsxs("div",{className:"flex items-center gap-2 border-b border-border/30 px-3 py-1.5",children:[i.jsx(m,{name:"file",className:"size-4 shrink-0 text-muted-foreground"}),i.jsx("span",{className:"typography-ui text-muted-foreground truncate flex-1",children:v}),i.jsx("button",{type:"button",onClick:()=>{h()},className:"size-6 flex items-center justify-center rounded-md text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",title:s("filesView.diagram.saveDiagram"),children:i.jsx(m,{name:"save-3",className:"size-4"})}),i.jsx("button",{type:"button",onClick:()=>n.getState().setActiveMainTab("chat"),className:"size-6 flex items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",title:s("filesView.diagram.closeDiagramView"),children:i.jsx(m,{name:"close",className:"size-4"})})]}),i.jsx("div",{className:"flex-1 min-h-0",children:i.jsx(y,{ref:c,xml:p,className:"h-full"})})]}):i.jsx("div",{className:"flex h-full items-center justify-center p-3",children:i.jsx("div",{className:"typography-ui text-muted-foreground",children:s("filesView.editor.pickFileFromTree")})})}export{Wi as DiagramView};
@@ -1,4 +1,4 @@
1
- import{R as o,j as n,f as pe}from"./vendor-react-BUCujlKS.js";import{u as J,C as Je,a as lt}from"./index-CNrN5qDs.js";import{f as me,U as ct,$ as Mt,aU as It,a1 as _t,a0 as zt,a2 as Bt,a3 as le,x as Ze,j as Pt,cr as Ot,t as Ie,hu as $t,aa as De,B as ue,I as _,g as ne,aW as Gt,aX as Kt,aY as Wt,gY as ft,hv as Ht,fa as qt,bV as dt,ac as ut,a9 as Ut,aQ as Xt,fd as Ke,aS as Yt,fe as Qt,aT as Jt}from"./useAppFontEffects-Bbpz77To.js";import{P as Zt}from"./PierreDiffViewer-B5k0KvPW.js";import{b as en,v as tn,g as nn,W as sn}from"./main-B4oBRI9u.js";import{f as rn}from"./patchFileDiff-DCIXUHRJ.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-D_V6hAcE.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-DKpLs02S.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./contextPanelEmbeddedChat-5VGWIT_J.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-DUOssd4j.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-CNWM3Q8V.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-DSzLbZiS.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Bbw3D7r0.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-BjbBRsUA.js";import"./vendor-codemirror-lang-json-ryCw7nab.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-VgNqFSH-.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-B3Qe3OpS.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-FGQydhTc.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-Dzt9rWZZ.js";import"./vendor-codemirror-lang-python-N414WYK-.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-ARAOgp1x.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CRSgBxjL.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./web-components-DGvnI0zx.js";import"./computeVirtualFileMetrics-DQE7R9IY.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./VirtualizedFileDiff-Dcu8Q-5P.js";import"./isDiffPlainText-XyBCe4eD.js";import"./vendor-diff-C3JhlQdm.js";import"./useInlineCommentController-D7zs7-BQ.js";import"./runtimeEndpointReset-D5izT-u5.js";import"./appThemeRegistry-BK0dHKa6.js";import"./registerCustomTheme-BBXUCRnG.js";import"./SessionSwitcherDropdown-ig2OT22Z.js";import"./scheduledTasksApi-CTJdfSWc.js";import"./vendor-cron-parser-CUcP7OfX.js";import"./vendor-luxon-BZ0puJYg.js";const et=(r,e)=>{if(e.length===0)return null;let i=null,a=null;for(const c of e)c.top<=r?(!i||c.top>i.top)&&(i=c):(!a||c.top<a.top)&&(a=c);const d=i??a;return d?{path:d.path,topOffset:d.top-r}:null},on=(r,e,i,a)=>Math.min(Math.max(0,a),Math.max(0,r+i-e)),tt=r=>{if(!r)return null;const e=r.split(`
1
+ import{R as o,j as n,f as pe}from"./vendor-react-BUCujlKS.js";import{u as Z,C as Ze,a as lt}from"./index-DRpChWux.js";import{f as me,V as ct,a0 as Mt,aV as It,a2 as _t,a1 as zt,a3 as Bt,a4 as le,y as Je,k as Pt,cq as Ot,t as Ie,hr as $t,ab as De,B as ue,I as _,h as ne,aX as Gt,aY as Kt,aZ as Wt,gV as ft,hs as Ht,f7 as qt,bU as dt,ad as ut,aa as Ut,aR as Xt,fa as Ke,aT as Yt,fb as Qt,aU as Zt}from"./useAppFontEffects-BikB6enL.js";import{P as Jt}from"./PierreDiffViewer-BHm4Yr0X.js";import{b as en,v as tn,g as nn,W as sn}from"./main-DPMd2iKS.js";import{f as rn}from"./patchFileDiff-KNkxM1C1.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-D_V6hAcE.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-DKpLs02S.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./contextPanelEmbeddedChat-B-bSg3P5.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-DUOssd4j.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-CNWM3Q8V.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-DSzLbZiS.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Bbw3D7r0.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-BjbBRsUA.js";import"./vendor-codemirror-lang-json-ryCw7nab.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-VgNqFSH-.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-B3Qe3OpS.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-FGQydhTc.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-CLHw8NWn.js";import"./vendor-codemirror-lang-python-N414WYK-.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-ARAOgp1x.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CRSgBxjL.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./web-components-GMc3oR3i.js";import"./computeVirtualFileMetrics-Da00Jg7M.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./VirtualizedFileDiff-CwGocYQd.js";import"./isDiffPlainText-D9YpoLrV.js";import"./vendor-diff-C3JhlQdm.js";import"./useInlineCommentController-CYPvYJDt.js";import"./runtimeEndpointReset-BVmispdD.js";import"./appThemeRegistry-BK0dHKa6.js";import"./registerCustomTheme-BBXUCRnG.js";import"./SessionSwitcherDropdown-rro-SsaO.js";import"./scheduledTasksApi-ByKya3Un.js";import"./vendor-cron-parser-CUcP7OfX.js";import"./vendor-luxon-BZ0puJYg.js";const et=(r,e)=>{if(e.length===0)return null;let i=null,a=null;for(const c of e)c.top<=r?(!i||c.top>i.top)&&(i=c):(!a||c.top<a.top)&&(a=c);const d=i??a;return d?{path:d.path,topOffset:d.top-r}:null},on=(r,e,i,a)=>Math.min(Math.max(0,a),Math.max(0,r+i-e)),tt=r=>{if(!r)return null;const e=r.split(`
2
2
  `);let i=null;for(const a of e){const d=a.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(d){const c=Number.parseInt(d[1]??"",10);i=Number.isFinite(c)&&c>=1?c:null;continue}if(i!==null){if(a.startsWith(" ")){i+=1;continue}if(a.startsWith("+"))return i;if(a.startsWith("-"))return Math.max(1,i)}}return null},an=1100,ln=15e3,nt=500,st=300,cn=1e6,fn=3,dn=r=>r<=6?r:r<=12?6:r<=25?4:2,un=o.memo(()=>{const r=pe.c(4),{t:e}=me();let i;r[0]!==e?(i=e("diffView.binary.unavailable"),r[0]=e,r[1]=i):i=r[1];let a;return r[2]!==i?(a=n.jsx("div",{className:"rounded-lg border border-border/60 bg-background px-3 py-2",children:n.jsx("div",{className:"typography-meta text-muted-foreground",children:i})}),r[2]=i,r[3]=a):a=r[3],a}),pt={"?":{code:"?",color:"var(--status-info)",descriptionKey:"diffView.change.untracked"},A:{code:"A",color:"var(--status-success)",descriptionKey:"diffView.change.new"},D:{code:"D",color:"var(--status-error)",descriptionKey:"diffView.change.deleted"},R:{code:"R",color:"var(--status-info)",descriptionKey:"diffView.change.renamed"},C:{code:"C",color:"var(--status-info)",descriptionKey:"diffView.change.copied"},M:{code:"M",color:"var(--status-warning)",descriptionKey:"diffView.change.modified"}},pn=pt.M,mn=r=>{const e=r.index?.trim(),i=r.working_dir?.trim();return e&&e!=="?"?e.charAt(0):i?i.charAt(0):e?.charAt(0)||i?.charAt(0)||"M"},mt=r=>{const e=mn(r);return pt[e]??pn},gn=r=>{const{index:e,working_dir:i}=r;return e==="A"||i==="A"||e==="?"||i==="?"},it=r=>{const e=r.index?.trim();return!!(e&&e!=="?")},rt=r=>!!r.working_dir?.trim()||r.index==="?",hn=(r,e)=>qt(r,e),ot=r=>(r||"").replace(/\\/g,"/").replace(/\/+$/,""),at=(r,e)=>{const i=r.split(`
3
3
  `),a=e.split(`
4
- `),d=Math.min(i.length,a.length);for(let c=0;c<d;c+=1)if(i[c]!==a[c])return c+1;return a.length>i.length?i.length+1:i.length>a.length?Math.max(1,a.length):1},xn=r=>/^Binary files .+ differ$/m.test(r)||/^GIT binary patch$/m.test(r),wn=r=>Array.isArray(r)?r.filter(e=>!e||typeof e!="object"?!1:typeof e.file=="string"):[],yn=r=>r==="added"?"A":r==="deleted"?"D":"M",gt=(r,e,i)=>xn(e)?{original:"",modified:"",isBinary:!0,patch:e,contextMode:i}:{original:"",modified:"",patch:e,fileDiff:rn(r,e),contextMode:i},ht=(r,e,i)=>{const a=r??0,d=e??0;return!a&&!d?null:n.jsxs("span",{className:ne("typography-meta flex items-center gap-1 text-xs whitespace-nowrap","flex-shrink-0",i?.className),children:[a?n.jsxs("span",{style:{color:"var(--status-success)"},children:["+",a]}):null,d?n.jsxs("span",{style:{color:"var(--status-error)"},children:["-",d]}):null]})},bn=o.memo(r=>{const e=pe.c(53),{scope:i,workingCount:a,stagedCount:d,turnCount:c,onScopeChange:g}=r,{t:p}=me(),[f,x]=o.useState(!1),w=i==="staged"?d:i==="turn"?c:a;let u;e[0]!==i||e[1]!==p?(u=p(i==="staged"?"diffView.scope.staged":i==="turn"?"diffView.scope.lastTurn":"diffView.scope.changed"),e[0]=i,e[1]=p,e[2]=u):u=e[2];const N=u;let y;e[3]!==p?(y=p("diffView.scope.selectorAria"),e[3]=p,e[4]=y):y=e[4];let D;e[5]!==w?(D=n.jsxs("span",{className:"diff-toolbar__scope-count",children:[": ",w]}),e[5]=w,e[6]=D):D=e[6];let T;e[7]!==N||e[8]!==D?(T=n.jsxs("span",{className:"whitespace-nowrap",children:[N,D]}),e[7]=N,e[8]=D,e[9]=T):T=e[9];let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(_,{name:"arrow-down-s",className:"size-4 flex-shrink-0 opacity-60"}),e[10]=k):k=e[10];let j;e[11]!==y||e[12]!==T?(j=n.jsx(Xt,{asChild:!0,children:n.jsxs("button",{type:"button",className:"flex h-7 flex-shrink-0 items-center gap-1.5 rounded-md px-2 typography-ui-label font-semibold text-foreground outline-none hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-ring","aria-label":y,children:[T,k]})}),e[11]=y,e[12]=T,e[13]=j):j=e[13];let M;e[14]!==g?(M=X=>{(X==="working"||X==="staged"||X==="turn")&&(g?.(X),x(!1))},e[14]=g,e[15]=M):M=e[15];let W;e[16]!==p?(W=p("diffView.scope.changed"),e[16]=p,e[17]=W):W=e[17];let H;e[18]!==W?(H=n.jsx("span",{children:W}),e[18]=W,e[19]=H):H=e[19];let Z;e[20]!==a?(Z=n.jsx("span",{className:"typography-meta text-muted-foreground",children:a}),e[20]=a,e[21]=Z):Z=e[21];let q;e[22]!==Z||e[23]!==H?(q=n.jsx(Ke,{value:"working",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[H,Z]})}),e[22]=Z,e[23]=H,e[24]=q):q=e[24];let U;e[25]!==p?(U=p("diffView.scope.staged"),e[25]=p,e[26]=U):U=e[26];let V;e[27]!==U?(V=n.jsx("span",{children:U}),e[27]=U,e[28]=V):V=e[28];let I;e[29]!==d?(I=n.jsx("span",{className:"typography-meta text-muted-foreground",children:d}),e[29]=d,e[30]=I):I=e[30];let ee;e[31]!==V||e[32]!==I?(ee=n.jsx(Ke,{value:"staged",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[V,I]})}),e[31]=V,e[32]=I,e[33]=ee):ee=e[33];let L;e[34]!==p?(L=p("diffView.scope.lastTurn"),e[34]=p,e[35]=L):L=e[35];let B;e[36]!==L?(B=n.jsx("span",{children:L}),e[36]=L,e[37]=B):B=e[37];let P;e[38]!==c?(P=n.jsx("span",{className:"typography-meta text-muted-foreground",children:c}),e[38]=c,e[39]=P):P=e[39];let E;e[40]!==B||e[41]!==P?(E=n.jsx(Ke,{value:"turn",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[B,P]})}),e[40]=B,e[41]=P,e[42]=E):E=e[42];let O;e[43]!==i||e[44]!==q||e[45]!==ee||e[46]!==E||e[47]!==M?(O=n.jsx(Yt,{align:"start",className:"w-40",children:n.jsxs(Qt,{value:i,onValueChange:M,children:[q,ee,E]})}),e[43]=i,e[44]=q,e[45]=ee,e[46]=E,e[47]=M,e[48]=O):O=e[48];let te;return e[49]!==f||e[50]!==O||e[51]!==j?(te=n.jsxs(Jt,{open:f,onOpenChange:x,children:[j,O]}),e[49]=f,e[50]=O,e[51]=j,e[52]=te):te=e[52],te}),vn=o.memo(r=>{const e=pe.c(11),{changedFiles:i,selectedFile:a,onSelectFile:d}=r,{t:c}=me();if(i.length===0)return null;let g;if(e[0]!==i||e[1]!==d||e[2]!==a||e[3]!==c){let f;e[5]!==d||e[6]!==a||e[7]!==c?(f=x=>{const w=mt(x),u=a===x.path;return n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>d(x.path),className:ne("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",u?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[n.jsx(ut,{filePath:x.path,className:"h-3.5 w-3.5 flex-shrink-0"}),n.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:{color:w.color},title:c(w.descriptionKey),"aria-label":c(w.descriptionKey),children:w.code}),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:x.path,children:x.path}),ht(x.insertions,x.deletions)]})},x.path)},e[5]=d,e[6]=a,e[7]=c,e[8]=f):f=e[8],g=i.map(f),e[0]=i,e[1]=d,e[2]=a,e[3]=c,e[4]=g}else g=e[4];let p;return e[9]!==g?(p=n.jsx(dt,{outerClassName:"flex-1 min-h-0",className:"px-2 py-2",children:n.jsx("ul",{className:"flex flex-col gap-1",children:g})}),e[9]=g,e[10]=p):p=e[10],p}),jn=o.memo(r=>{const e=pe.c(20),{filePath:i,diff:a,renderSideBySide:d}=r,{t:c}=me(),g=a.original.length>0,p=a.modified.length>0,f=d?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",x=d?"flex flex-col items-center gap-2 flex-1 min-w-0":"flex flex-col items-center gap-2";let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w={contain:"layout"},e[0]=w):w=e[0];let u;e[1]!==a.original||e[2]!==i||e[3]!==g||e[4]!==x||e[5]!==d||e[6]!==c?(u=g&&n.jsxs("div",{className:x,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:c("diffView.image.original")}),n.jsx("img",{src:a.original,alt:c("diffView.image.originalAlt",{path:i}),className:d?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[1]=a.original,e[2]=i,e[3]=g,e[4]=x,e[5]=d,e[6]=c,e[7]=u):u=e[7];let N;e[8]!==a.modified||e[9]!==i||e[10]!==p||e[11]!==g||e[12]!==x||e[13]!==d||e[14]!==c?(N=p&&n.jsxs("div",{className:x,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:c(g?"diffView.image.modified":"diffView.image.new")}),n.jsx("img",{src:a.modified,alt:c("diffView.image.modifiedAlt",{path:i}),className:d?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[8]=a.modified,e[9]=i,e[10]=p,e[11]=g,e[12]=x,e[13]=d,e[14]=c,e[15]=N):N=e[15];let y;return e[16]!==f||e[17]!==u||e[18]!==N?(y=n.jsx("div",{className:"w-full overflow-auto p-4",style:w,children:n.jsxs("div",{className:f,children:[u,N]})}),e[16]=f,e[17]=u,e[18]=N,e[19]=y):y=e[19],y}),Sn=o.memo(r=>{const e=pe.c(16),{filePath:i,diff:a,renderSideBySide:d,wrapLines:c}=r;let g;e[0]!==i?(g=Ut(i)||"text",e[0]=i,e[1]=g):g=e[1];const p=g;if(a.isBinary){let w;return e[2]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(un,{}),e[2]=w):w=e[2],w}if(De(i)){let w;return e[3]!==a||e[4]!==i||e[5]!==d?(w=n.jsx(jn,{filePath:i,diff:a,renderSideBySide:d}),e[3]=a,e[4]=i,e[5]=d,e[6]=w):w=e[6],w}let f;e[7]===Symbol.for("react.memo_cache_sentinel")?(f={contain:"layout"},e[7]=f):f=e[7];let x;return e[8]!==a.fileDiff||e[9]!==a.modified||e[10]!==a.original||e[11]!==i||e[12]!==p||e[13]!==d||e[14]!==c?(x=n.jsx("div",{className:"w-full",style:f,children:n.jsx(Zt,{original:a.original,modified:a.modified,fileDiff:a.fileDiff,language:p,fileName:i,renderSideBySide:d,wrapLines:c,layout:"inline"})}),e[8]=a.fileDiff,e[9]=a.modified,e[10]=a.original,e[11]=i,e[12]=p,e[13]=d,e[14]=c,e[15]=x):x=e[15],x}),Nn=o.memo(r=>{const e=pe.c(7),{filePath:i,staged:a,busyAction:d,disabled:c,onAction:g}=r,{t:p}=me();let f;return e[0]!==d||e[1]!==c||e[2]!==i||e[3]!==g||e[4]!==a||e[5]!==p?(f=n.jsx("div",{className:"flex items-center gap-0.5 rounded-full border border-[var(--interactive-border)]/45 bg-[var(--surface-background)]/95 px-1 py-0.5 shadow-sm backdrop-blur-md",children:a?n.jsx(We,{label:p("gitView.changes.unstageFileAria",{path:i}),icon:"arrow-go-back",loading:d==="unstage",disabled:c,onClick:()=>g("unstage")}):n.jsxs(n.Fragment,{children:[n.jsx(We,{label:p("gitView.changes.revertFileAria",{path:i}),icon:"arrow-go-back",loading:d==="discard",disabled:c,tone:"failure",onClick:()=>g("discard")}),n.jsx(We,{label:p("gitView.changes.stageFileAria",{path:i}),icon:"add",loading:d==="stage",disabled:c,tone:"success",onClick:()=>g("stage")})]})}),e[0]=d,e[1]=c,e[2]=i,e[3]=g,e[4]=a,e[5]=p,e[6]=f):f=e[6],f}),We=r=>{const e=pe.c(14),{label:i,icon:a,loading:d,disabled:c,tone:g,onClick:p}=r,f=g==="failure"&&"text-[var(--status-error)] hover:text-[var(--status-error)]",x=g==="success"&&"text-[var(--status-success)] hover:text-[var(--status-success)]";let w;e[0]!==f||e[1]!==x?(w=ne("h-6 w-6 rounded-none bg-transparent p-0 text-muted-foreground opacity-70 hover:bg-transparent hover:text-foreground hover:opacity-100",f,x),e[0]=f,e[1]=x,e[2]=w):w=e[2];let u;e[3]!==p?(u=D=>{D.stopPropagation(),p()},e[3]=p,e[4]=u):u=e[4];let N;e[5]!==a||e[6]!==d?(N=d?n.jsx(_,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(_,{name:a,className:a==="add"?"size-4":"size-3.5"}),e[5]=a,e[6]=d,e[7]=N):N=e[7];let y;return e[8]!==c||e[9]!==i||e[10]!==w||e[11]!==u||e[12]!==N?(y=n.jsx(ue,{variant:"ghost",size:"sm",className:w,disabled:c,title:i,"aria-label":i,onClick:u,children:N}),e[8]=c,e[9]=i,e[10]=w,e[11]=u,e[12]=N,e[13]=y):y=e[13],y},Fn=o.memo(({directory:r,file:e,layout:i,wrapLines:a,isSelected:d,isExpanded:c,isMounted:g,onSelect:p,onExpandedChange:f,registerSectionRef:x,showOpenInEditorAction:w=!1,isOpeningInEditor:u=!1,onOpenInEditor:N,staged:y=!1,loadFullFiles:D=!1,initialDiffData:T=null})=>{const{t:k}=me(),{git:j}=ct(),M=le(o.useCallback(m=>m.directories.get(r)?.diffCache.get(e.path)??null,[r,e.path])),W=le(m=>m.setDiff),H=le(m=>m.fetchStatus),Z=J(m=>m.setDiffFileLayout),[q,U]=o.useState(0),[V,I]=o.useState(null),[ee,L]=o.useState(!1),[B,P]=o.useState(null),[E,O]=o.useState(!1),[te,X]=o.useState(null),[se,je]=o.useState(null),ie=o.useRef(null),Se=o.useRef(null),ce=o.useMemo(()=>mt(e),[e]),Re=i==="side-by-side",ge=D?"full":"patch",fe=`${e.index}:${e.working_dir}:${e.insertions}:${e.deletions}`,Y=o.useMemo(()=>T||(y?se:te||(M?{original:M.original,modified:M.modified,isBinary:M.isBinary,contextMode:"full"}:null)),[M,T,te,y,se]),Ne=Y?.contextMode===ge,b=o.useCallback(m=>{Se.current=m,x(e.path,m)},[e.path,x]),he=o.useCallback(m=>{f(e.path,m)},[e.path,f]),re=o.useCallback(()=>{p(e.path)},[e.path,p]);o.useEffect(()=>{y?je(null):X(null),I(null),ie.current=null},[fe,y]),o.useEffect(()=>{if(!c||!g)return;if(!r||T||Y&&Ne){ie.current=null,L(!1);return}const m=`${r}::${e.path}::${y?"staged":"unstaged"}::${fe}::${ge}::${q}`;if(ie.current===m)return;ie.current=m,I(null),L(!0);let C=!1;const ae=lt(),Ae=D?cn:fn,Ve=De(e.path)?j.getGitFileDiff(r,{path:e.path,staged:y}):j.getGitDiff(r,{path:e.path,staged:y,contextLines:Ae}),Le=ln,Ee=new Promise((R,$)=>{setTimeout(()=>$(new Error(`Timed out after ${Le}ms`)),Le)});return Promise.race([Ve,Ee]).then(R=>{if(!C){if("diff"in R){const $=gt(e.path,R.diff,ge);y?je($):X($)}else{const $={original:R.original??"",modified:R.modified??"",isBinary:R.isBinary,contextMode:"full"};y?je($):W(r,e.path,$,ae)}L(!1)}}).catch(R=>{if(C)return;const $=R instanceof Error?R.message:String(R);I($),L(!1)}),()=>{C=!0,ie.current===m&&(ie.current=null)}},[ge,Y,Ne,q,r,e.path,fe,j,T,c,g,D,W,y]);const Fe=o.useCallback(()=>{he(!c),re()},[he,re,c]),oe=o.useCallback(async m=>{if(!(!r||B!==null)){P(m);try{m==="stage"?await j.stageGitFile(r,e.path):m==="unstage"?await j.unstageGitFile(r,e.path):await j.revertGitFile(r,e.path,{scope:"working"}),U(C=>C+1),await H(r,j)}catch(C){const ae=m==="unstage"?"gitView.toast.unstageFileFailed":m==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.revertFailed";Ie.error(C instanceof Error?C.message:k(ae))}finally{P(C=>C===m?null:C)}}},[r,H,e.path,B,j,k]);return n.jsxs("div",{ref:b,className:"scroll-mt-9 border-b border-[var(--interactive-border)]/40 last:border-b-0",children:[n.jsx("div",{className:"sticky top-0 z-30 border-b border-[var(--interactive-border)]/35 bg-[var(--surface-elevated)]/90 backdrop-blur-md supports-[backdrop-filter]:bg-[var(--surface-elevated)]/80",children:n.jsxs("div",{role:"button",tabIndex:0,onClick:Fe,onKeyDown:m=>{m.target===m.currentTarget&&(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),Fe())},className:ne("cursor-pointer","group/header relative grid min-h-9 w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2 overflow-hidden px-3 py-2","bg-transparent","text-muted-foreground hover:text-foreground",d?"bg-[var(--interactive-selection)]/35":null),children:[n.jsx("div",{className:"absolute inset-0 pointer-events-none group-hover/header:bg-[var(--interactive-hover)]/50"}),n.jsxs("div",{className:"relative flex min-w-0 flex-1 items-center gap-2",children:[n.jsx("span",{className:"flex size-5 items-center justify-center opacity-70 group-hover/header:opacity-100",children:c?n.jsx(_,{name:"arrow-down-s",className:"size-4"}):n.jsx(_,{name:"arrow-right-s",className:"size-4"})}),n.jsx("span",{className:"typography-micro font-semibold leading-none w-4 text-center uppercase",style:{color:ce.color},title:k(ce.descriptionKey),"aria-label":k(ce.descriptionKey),children:ce.code}),n.jsx("span",{className:"min-w-0 flex-1 overflow-hidden typography-ui-label",title:e.path,children:n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(ut,{filePath:e.path,className:"h-3.5 w-3.5 flex-shrink-0 align-middle"}),(()=>{const m=e.path.lastIndexOf("/");if(m===-1)return n.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:e.path});const C=e.path.slice(0,m),ae=e.path.slice(m+1);return n.jsxs("span",{className:"flex min-w-0 items-baseline overflow-hidden",children:[n.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:C}),n.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[n.jsx("span",{className:"text-muted-foreground",children:"/"}),n.jsx("span",{className:"text-foreground",children:ae})]})]})})()]})})]}),n.jsxs("div",{className:"relative flex shrink-0 items-center justify-self-end gap-2",children:[ht(e.insertions,e.deletions),w&&N?n.jsx(ue,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:k("diffView.actions.openFileInEditorAtChange"),onClick:m=>{m.stopPropagation(),N(e.path,Y)},disabled:u,children:u?n.jsx(_,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(_,{name:"edit",className:"size-3.5"})}):null,n.jsx(ft,{mode:Re?"side-by-side":"unified",onModeChange:m=>{const C=m==="side-by-side"?"side-by-side":"inline";Z(e.path,C)},className:"opacity-70"})]})]})}),c&&n.jsxs("div",{className:"relative bg-background overflow-hidden",children:[!g&&!V?n.jsx("div",{className:"h-40 border border-border/40 bg-background/40"}):null,V?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:k("diffView.state.failedToLoadDiff")}),n.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:V}),n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>U(m=>m+1),children:k("diffView.actions.retry")})]}):null,g&&ee&&!Y&&!V?n.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx(_,{name:"loader-4",className:"size-4 animate-spin"}),k("diffView.state.loadingDiff")]}):null,g&&Y&&!E&&e.insertions+e.deletions>nt?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:k("diffView.state.largeDiff",{count:e.insertions+e.deletions})}),n.jsx("div",{className:"typography-meta text-muted-foreground",children:k("diffView.state.largeDiffDescription")}),n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>O(!0),children:k("diffView.actions.renderAnyway")})]}):null,g&&Y&&(E||e.insertions+e.deletions<=nt)?n.jsxs(n.Fragment,{children:[n.jsx(Sn,{filePath:e.path,diff:Y,renderSideBySide:Re,wrapLines:a}),n.jsx("div",{className:"pointer-events-none absolute bottom-3 right-3 z-20",children:n.jsx("div",{className:"pointer-events-auto",children:n.jsx(Nn,{filePath:e.path,staged:y,busyAction:B,disabled:B!==null,onAction:oe})})})]}):null]})]})}),zi=({hideStackedFileSidebar:r=!1,stackedDefaultCollapsedAll:e=!1,pinSelectedFileHeaderToTopOnNavigate:i=!1,showOpenInEditorAction:a=!1,diffScope:d="all",onDiffScopeChange:c,targetFilePath:g=null,flushContent:p=!1})=>{const{t:f}=me(),{git:x,files:w}=ct(),u=Mt(),N=J(t=>t.openContextSurface),y=en(t=>t.requestSource),{screenWidth:D,isMobile:T}=It(),k=_t(u??null),j=zt(u??null),M=Bt(u??null),W=le(t=>t.setActiveDirectory),H=le(t=>t.ensureStatus),Z=le(t=>t.fetchStatus),q=le(t=>t.clearDiffCache),U=le(t=>t.setDiff),[V,I]=o.useState(null),[ee,L]=o.useState(!1),[B,P]=o.useState(null),[E,O]=o.useState(()=>new Set),[te,X]=o.useState(()=>new Set),[se,je]=o.useState(!1),[ie,Se]=o.useState(0),[ce,Re]=o.useState(()=>new Map),[ge,fe]=o.useState(!1),[Y,Ne]=o.useState(!1),[b,he]=o.useState(d);o.useEffect(()=>{he(d)},[d]);const re=J(t=>t.pendingDiffFile),Fe=J(t=>t.pendingDiffStaged),oe=J(t=>t.pendingDiffScope),m=J(t=>t.setPendingDiffFile),C=J(t=>t.diffLayoutPreference),ae=J(t=>t.diffFileLayout),Ae=J(t=>t.setDiffFileLayout),Ve=J(t=>t.diffWrapLines),Le=J(t=>t.setDiffWrapLines),Ee=J(t=>t.openContextFileAtLine),R=Ze(t=>t.currentSessionId),$=Pt(R??"",u??void 0),_e=Ve,ze=b==="staged"?!0:b==="working"?!1:null,Te=ze??ee,Be=T||D<=768,xt=!!R&&b!=="turn"&&!Be&&!Je(),wt=b!=="turn"&&!Be&&!Je(),yt=!r&&!Be&&D>=1024,xe=o.useRef(null),Ce=o.useRef(new Map),de=o.useRef(null),z=o.useRef(null),we=o.useRef(!1),ye=o.useRef(null),He=o.useRef(null),Pe=o.useRef(null),Oe=o.useRef(null),qe=o.useCallback(()=>{const t=xe.current;if(!t)return null;const s=t.getBoundingClientRect().top,l=[];for(const[h,v]of Ce.current)v&&l.push({path:h,top:v.getBoundingClientRect().top});return et(s,l)},[]),be=o.useCallback(()=>{de.current=null,we.current=!1,P(null),z.current!==null&&(window.cancelAnimationFrame(z.current),z.current=null)},[]),ve=o.useCallback(t=>{O(s=>{if(s.has(t))return s;const l=new Set(s);return l.add(t),l})},[]),ke=o.useMemo(()=>{for(let t=$.length-1;t>=0;t-=1){const s=$[t];if(s.role==="user")return wn(s.summary?.diffs)}return[]},[$]),bt=o.useMemo(()=>{const t=new Map;for(const s of ke)if(s.file){if(typeof s.patch=="string"){t.set(s.file,gt(s.file,s.patch,"patch"));continue}t.set(s.file,{original:s.before??"",modified:s.after??"",contextMode:"full"})}return t},[ke]),S=o.useMemo(()=>{if(b==="turn")return ke.map(l=>({path:l.file??"",index:"",working_dir:yn(l.status),insertions:l.additions??0,deletions:l.deletions??0,isNew:l.status==="added"})).filter(l=>l.path).sort((l,h)=>l.path.localeCompare(h.path));if(!j?.files)return[];const t=j.diffStats??{},s=b==="staged"?it:b==="working"?rt:()=>!0;return j.files.filter(s).map(l=>({...l,insertions:t[l.path]?.insertions??0,deletions:t[l.path]?.deletions??0,isNew:gn(l)})).sort((l,h)=>l.path.localeCompare(h.path))},[b,ke,j]),vt=o.useMemo(()=>j?.files?j.files.filter(rt).length:0,[j]),jt=o.useMemo(()=>j?.files?j.files.filter(it).length:0,[j]),St=ke.length,$e=o.useMemo(()=>S.map(t=>t.path).join("\0"),[S]);o.useEffect(()=>{const t=$e?$e.split("\0"):[],s=new Set(t),l=`${u??""}:${b}:${e?"collapsed":"default"}`,h=He.current!==l;He.current=l,O(v=>{if(h){const A=e?0:dn(t.length);return new Set(t.slice(0,A))}let G=!1;const F=new Set;for(const A of v){if(!s.has(A)){G=!0;continue}F.add(A)}return G?F:v}),X(v=>{if(h)return new Set;let G=!1;const F=new Set;for(const A of v){if(!s.has(A)){G=!0;continue}F.add(A)}return G?F:v})},[b,$e,u,e]);const Ue=o.useCallback(()=>{ye.current=null;const t=xe.current;if(!t)return;const s=t.getBoundingClientRect(),l=s.top-st,h=s.bottom+st,v={},G=[];for(const[F,A]of Ce.current){if(!A)continue;const K=A.getBoundingClientRect();G.push({path:F,top:K.top}),E.has(F)&&(K.bottom<l||K.top>h||(v[F]=!0))}Pe.current=et(s.top,G),X(F=>{let A=!1;const K=new Set(F);for(const Qe of Object.keys(v))K.has(Qe)||(K.add(Qe),A=!0);return A?K:F})},[E]),Q=o.useCallback(()=>{typeof window>"u"||ye.current===null&&(ye.current=window.requestAnimationFrame(Ue))},[Ue]);o.useEffect(()=>{const t=xe.current;if(t)return Q(),t.addEventListener("scroll",Q,{passive:!0}),window.addEventListener("resize",Q),()=>{t.removeEventListener("scroll",Q),window.removeEventListener("resize",Q),ye.current!==null&&(window.cancelAnimationFrame(ye.current),ye.current=null)}},[S,E,Q]);const Ge=o.useCallback(t=>{const s=ae[t.path];if(s)return s;if(C==="inline")return"inline";if(C==="side-by-side")return"side-by-side";const l=D<an;return t.isNew||l?"inline":"side-by-side"},[ae,C,D]),Xe=o.useMemo(()=>S.length===0?null:S.every(t=>Ge(t)==="side-by-side")?"side-by-side":"inline",[S,Ge]);o.useEffect(()=>{u&&(W(u),H(u,x))},[u,W,H,x]),o.useEffect(()=>{if(u)return Ot.onGitRefreshHint(t=>{ot(t.directory)===ot(u)&&(t.paths?.length&&(Oe.current=qe()??Pe.current,q(u,t.paths),Re(s=>{const l=new Map(s);for(const h of t.paths??[])l.set(h,(l.get(h)??0)+1);return l})),Z(u,x,{silent:!0}))})},[qe,q,u,Z,x]),o.useLayoutEffect(()=>{const t=Oe.current;if(!t)return;Oe.current=null;const s=xe.current,l=Ce.current.get(t.path);if(!s||!l)return;const h=s.getBoundingClientRect().top,v=l.getBoundingClientRect().top-h;s.scrollTop=on(s.scrollTop,t.topOffset,v,s.scrollHeight-s.clientHeight),Pe.current=t},[ce]),o.useEffect(()=>{b!=="all"&&!oe||re&&(oe&&he(oe),I(re),L(oe==="staged"||!oe&&Fe),m(null),we.current=!0,de.current=re,ve(re),Se(t=>t+1))},[b,ve,re,oe,Fe,m]),o.useEffect(()=>{if(b==="all")return;const t=g?.trim();t&&(I(t),L(b==="staged"),we.current=!0,de.current=t,ve(t),Se(s=>s+1))},[b,ve,g]),o.useEffect(()=>{if(!V)return;S.some(s=>s.path===V)||(I(null),L(!1))},[S,V]);const Nt=o.useCallback((t,s)=>{const l=Ce.current;s?l.set(t,s):l.delete(t),Q()},[Q]),Ft=o.useCallback((t,s)=>{be(),O(l=>{const h=l.has(t);if(s===h)return l;const v=new Set(l);return s?v.add(t):v.delete(t),v}),s||X(l=>{if(!l.has(t))return l;const h=new Set(l);return h.delete(t),h}),Q()},[be,Q]),Ct=o.useCallback(()=>{be(),O(t=>t.size>0?new Set:new Set(S.map(s=>s.path))),X(new Set),Q()},[be,S,Q]),kt=o.useCallback(async t=>{if(!R)return;const s=Ze.getState().getDirectoryForSession(R)||u||"";if(!s){Ie.error(f("diffView.reviewDialog.toast.noSessionDirectory"));return}Ne(!0);try{await $t({originalSessionID:R,directory:s,providerID:t.providerID,modelID:t.modelID,agent:t.agent||void 0,variant:t.variant||void 0,generateHandoff:t.generateHandoff,returnAfterHandoffRequest:t.generateHandoff,autoReview:t.autoReview}),fe(!1)}catch(l){console.error("[review-flow] failed to start review flow",l),Ie.error(l instanceof Error?l.message:f("diffView.reviewDialog.toast.startFailed"))}finally{Ne(!1)}},[R,u,f]),Me=o.useCallback(t=>{const s=Ce.current.get(t),l=xe.current;if(!s||!l)return!1;const h=s.getBoundingClientRect().top-l.getBoundingClientRect().top;return l.scrollTo({top:l.scrollTop+h,behavior:"auto"}),!0},[]);o.useEffect(()=>{if(!de.current)return;let s=0;const l=20;let h=!1;const v=(F=!0)=>{h||(h=!0,de.current=null,we.current=!1,F&&P(null),z.current!==null&&(window.cancelAnimationFrame(z.current),z.current=null))},G=()=>{if(h){z.current=null;return}const F=de.current;if(!F){v(),z.current=null;return}if(!Me(F)){s+=1,s<l?z.current=window.requestAnimationFrame(G):(v(),z.current=null);return}if(i&&we.current){P(F),v(!1);return}v()};return z.current=window.requestAnimationFrame(G),()=>{h=!0,z.current!==null&&(window.cancelAnimationFrame(z.current),z.current=null)}},[i,ie,Me]);const Dt=o.useCallback(t=>{},[]),Rt=o.useCallback(t=>{be(),I(t),L(!1),we.current=!0,de.current=t,ve(t),Se(s=>s+1),Me(t)},[be,ve,Me]),At=o.useCallback(t=>{const s=t==="side-by-side"?"side-by-side":"inline";S.forEach(l=>{Ae(l.path,s)})},[S,Ae]),[Vt,Ye]=o.useState(null),Lt=o.useCallback(async(t,s)=>{if(!u||!t)return;Ye(t);const l=lt();try{let h=null;if(s?.patch&&!s.isBinary&&!De(t)?h=tt(s.patch):s&&s.contextMode==="full"&&!s.isBinary&&!De(t)&&(h=at(s.original,s.modified)),h===null)try{const K=await x.getGitDiff(u,{path:t,staged:Te,contextLines:3});h=tt(K.diff)}catch{h=null}let v=s;if(h===null||!v){const K=await x.getGitFileDiff(u,{path:t,staged:Te});v={original:K.original??"",modified:K.modified??"",isBinary:K.isBinary},Te||U(u,t,v,l)}const G=h??(v.isBinary||De(t)?1:at(v.original,v.modified)),F=hn(u,t),A=await tn(w,F,{directory:u});if(!A.ok){Ie.error(nn(A.reason));return}Ee(u,F,G,1)}finally{Ye(h=>h===t?null:h)}},[Te,u,w,x,Ee,U]),Et=()=>{if(!u)return null;const t=s=>ze!==null?ze:ee&&s===V;return n.jsxs("div",{className:ne("flex min-w-0 flex-1 min-h-0 h-full",p?"gap-0":"gap-3 px-3 pb-3 pt-2"),children:[yt&&n.jsxs("section",{className:"hidden lg:flex w-72 flex-col rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/40",children:[n.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:f("diffView.section.files")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:S.length})]}),n.jsx(vn,{changedFiles:S,selectedFile:null,onSelectFile:Rt})]}),n.jsx("div",{className:"relative flex-1 min-w-0 min-h-0 h-full",children:n.jsx(dt,{ref:xe,outerClassName:"min-h-0 h-full",className:"[overflow-anchor:none] pb-16",disableHorizontal:!0,observeMutations:!1,preventOverscroll:!0,"data-diff-virtual-root":!0,children:n.jsx("div",{className:"flex flex-col [overflow-anchor:none]","data-diff-virtual-content":!0,children:S.map(s=>n.jsx(Fn,{directory:u,file:s,layout:Ge(s),wrapLines:_e,isSelected:!1,isExpanded:E.has(s.path),isMounted:te.has(s.path)||s.path===B,onSelect:Dt,onExpandedChange:Ft,registerSectionRef:Nt,showOpenInEditorAction:a&&b!=="turn",isOpeningInEditor:Vt===s.path,onOpenInEditor:(l,h)=>{Lt(l,h)},staged:t(s.path),loadFullFiles:se,initialDiffData:b==="turn"?bt.get(s.path)??null:null},`${s.path}:${ce.get(s.path)??0}`))})})})]})},Tt=()=>u?b!=="turn"&&M&&!j?n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(_,{name:"loader-4",className:"size-4 animate-spin"}),f("diffView.state.loadingRepositoryStatus")]}):b!=="turn"&&k===!1?n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:f("diffView.state.notGitRepository")}):S.length===0?n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:f(b==="turn"?"diffView.state.noLastTurnChanges":"diffView.state.cleanWorkingTree")}):Et():n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:f("diffView.state.selectSessionDirectory")});return n.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background",children:[n.jsxs("div",{className:"@container/diff-toolbar flex min-w-0 items-center gap-2 px-3 py-2 bg-background",children:[!T&&(b==="working"||b==="staged"||b==="turn"?n.jsx(bn,{scope:b,workingCount:vt,stagedCount:jt,turnCount:St,onScopeChange:t=>{he(t),c?.(t)}}):n.jsx("div",{className:"flex items-center gap-1 rounded-md px-2 py-1 text-muted-foreground shrink-0",children:n.jsx("span",{className:"typography-ui-label font-semibold text-foreground",children:M&&!j?f("diffView.state.loadingChanges"):S.length===1?f("diffView.summary.changedFilesSingle",{count:S.length}):f("diffView.summary.changedFilesPlural",{count:S.length})})})),S.length>0&&n.jsxs(ue,{variant:"ghost",size:"sm",onClick:Ct,className:ne("diff-toolbar__expand-button h-7 flex-shrink-0 gap-1 px-1.5 text-muted-foreground hover:text-foreground","ml-auto"),title:E.size>0?f("diffView.actions.collapseAll"):f("diffView.actions.expandAll"),children:[n.jsx(_,{name:"expand-up-down",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:E.size>0?f("diffView.actions.collapseAll"):f("diffView.actions.expandAll")})]}),S.length>0&&xt&&n.jsxs(ue,{variant:"default",size:"sm",onClick:()=>fe(!0),disabled:Y,className:"diff-toolbar__review-button h-7 flex-shrink-0 gap-1.5 px-2","aria-label":f("diffView.actions.reviewAria"),children:[Y?n.jsx(_,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx(_,{name:"search-eye",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__review-label typography-ui-label",children:f("diffView.actions.review")})]}),S.length>0&&wt&&n.jsxs(ue,{variant:"outline",size:"sm",onClick:()=>{const t=u??"";y(t,{kind:"working-tree",scope:b==="staged"||b==="working"?b:"all"}),N(t,"walkthrough")},className:ne("diff-toolbar__walkthrough-button h-7 flex-shrink-0 gap-1.5 px-2",sn),"aria-label":f("walkthrough.action.open"),children:[n.jsx(_,{name:"route",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__walkthrough-label typography-ui-label",children:f("walkthrough.action.open")})]}),S.length>0&&n.jsxs(Gt,{children:[n.jsx(Kt,{asChild:!0,children:n.jsx(ue,{variant:"ghost",size:"sm",onClick:()=>je(t=>!t),"aria-pressed":se,"aria-label":f(se?"diffView.actions.disableFullFiles":"diffView.actions.loadFullFiles"),className:ne("h-7 w-7 flex-shrink-0 p-0 text-muted-foreground hover:text-foreground",se&&"bg-interactive-selection text-interactive-selection-foreground"),children:n.jsx(_,{name:"file-download",className:"size-4"})})}),n.jsx(Wt,{children:n.jsx("p",{children:f(se?"diffView.actions.disableFullFiles":"diffView.actions.loadFullFiles")})})]}),S.length>0&&n.jsx(ue,{variant:"ghost",size:"sm",onClick:()=>Le(!Ve),className:ne("h-5 w-5 p-0 transition-opacity",_e?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:f(_e?"diffView.actions.disableLineWrap":"diffView.actions.enableLineWrap"),children:n.jsx(_,{name:"text-wrap",className:"size-4"})}),Xe&&n.jsx(ft,{mode:Xe==="side-by-side"?"side-by-side":"unified",onModeChange:At})]}),n.jsx(Ht,{open:ge,onOpenChange:fe,projectDirectory:u??null,submitting:Y,onConfirm:kt}),Tt()]})};export{zi as DiffView};
4
+ `),d=Math.min(i.length,a.length);for(let c=0;c<d;c+=1)if(i[c]!==a[c])return c+1;return a.length>i.length?i.length+1:i.length>a.length?Math.max(1,a.length):1},xn=r=>/^Binary files .+ differ$/m.test(r)||/^GIT binary patch$/m.test(r),wn=r=>Array.isArray(r)?r.filter(e=>!e||typeof e!="object"?!1:typeof e.file=="string"):[],yn=r=>r==="added"?"A":r==="deleted"?"D":"M",gt=(r,e,i)=>xn(e)?{original:"",modified:"",isBinary:!0,patch:e,contextMode:i}:{original:"",modified:"",patch:e,fileDiff:rn(r,e),contextMode:i},ht=(r,e,i)=>{const a=r??0,d=e??0;return!a&&!d?null:n.jsxs("span",{className:ne("typography-meta flex items-center gap-1 text-xs whitespace-nowrap","flex-shrink-0",i?.className),children:[a?n.jsxs("span",{style:{color:"var(--status-success)"},children:["+",a]}):null,d?n.jsxs("span",{style:{color:"var(--status-error)"},children:["-",d]}):null]})},bn=o.memo(r=>{const e=pe.c(53),{scope:i,workingCount:a,stagedCount:d,turnCount:c,onScopeChange:g}=r,{t:p}=me(),[f,x]=o.useState(!1),w=i==="staged"?d:i==="turn"?c:a;let u;e[0]!==i||e[1]!==p?(u=p(i==="staged"?"diffView.scope.staged":i==="turn"?"diffView.scope.lastTurn":"diffView.scope.changed"),e[0]=i,e[1]=p,e[2]=u):u=e[2];const N=u;let y;e[3]!==p?(y=p("diffView.scope.selectorAria"),e[3]=p,e[4]=y):y=e[4];let D;e[5]!==w?(D=n.jsxs("span",{className:"diff-toolbar__scope-count",children:[": ",w]}),e[5]=w,e[6]=D):D=e[6];let T;e[7]!==N||e[8]!==D?(T=n.jsxs("span",{className:"whitespace-nowrap",children:[N,D]}),e[7]=N,e[8]=D,e[9]=T):T=e[9];let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(_,{name:"arrow-down-s",className:"size-4 flex-shrink-0 opacity-60"}),e[10]=k):k=e[10];let j;e[11]!==y||e[12]!==T?(j=n.jsx(Xt,{asChild:!0,children:n.jsxs("button",{type:"button",className:"flex h-7 flex-shrink-0 items-center gap-1.5 rounded-md px-2 typography-ui-label font-semibold text-foreground outline-none hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-ring","aria-label":y,children:[T,k]})}),e[11]=y,e[12]=T,e[13]=j):j=e[13];let M;e[14]!==g?(M=X=>{(X==="working"||X==="staged"||X==="turn")&&(g?.(X),x(!1))},e[14]=g,e[15]=M):M=e[15];let W;e[16]!==p?(W=p("diffView.scope.changed"),e[16]=p,e[17]=W):W=e[17];let H;e[18]!==W?(H=n.jsx("span",{children:W}),e[18]=W,e[19]=H):H=e[19];let J;e[20]!==a?(J=n.jsx("span",{className:"typography-meta text-muted-foreground",children:a}),e[20]=a,e[21]=J):J=e[21];let q;e[22]!==J||e[23]!==H?(q=n.jsx(Ke,{value:"working",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[H,J]})}),e[22]=J,e[23]=H,e[24]=q):q=e[24];let U;e[25]!==p?(U=p("diffView.scope.staged"),e[25]=p,e[26]=U):U=e[26];let V;e[27]!==U?(V=n.jsx("span",{children:U}),e[27]=U,e[28]=V):V=e[28];let I;e[29]!==d?(I=n.jsx("span",{className:"typography-meta text-muted-foreground",children:d}),e[29]=d,e[30]=I):I=e[30];let ee;e[31]!==V||e[32]!==I?(ee=n.jsx(Ke,{value:"staged",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[V,I]})}),e[31]=V,e[32]=I,e[33]=ee):ee=e[33];let L;e[34]!==p?(L=p("diffView.scope.lastTurn"),e[34]=p,e[35]=L):L=e[35];let B;e[36]!==L?(B=n.jsx("span",{children:L}),e[36]=L,e[37]=B):B=e[37];let P;e[38]!==c?(P=n.jsx("span",{className:"typography-meta text-muted-foreground",children:c}),e[38]=c,e[39]=P):P=e[39];let E;e[40]!==B||e[41]!==P?(E=n.jsx(Ke,{value:"turn",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[B,P]})}),e[40]=B,e[41]=P,e[42]=E):E=e[42];let O;e[43]!==i||e[44]!==q||e[45]!==ee||e[46]!==E||e[47]!==M?(O=n.jsx(Yt,{align:"start",className:"w-40",children:n.jsxs(Qt,{value:i,onValueChange:M,children:[q,ee,E]})}),e[43]=i,e[44]=q,e[45]=ee,e[46]=E,e[47]=M,e[48]=O):O=e[48];let te;return e[49]!==f||e[50]!==O||e[51]!==j?(te=n.jsxs(Zt,{open:f,onOpenChange:x,children:[j,O]}),e[49]=f,e[50]=O,e[51]=j,e[52]=te):te=e[52],te}),vn=o.memo(r=>{const e=pe.c(11),{changedFiles:i,selectedFile:a,onSelectFile:d}=r,{t:c}=me();if(i.length===0)return null;let g;if(e[0]!==i||e[1]!==d||e[2]!==a||e[3]!==c){let f;e[5]!==d||e[6]!==a||e[7]!==c?(f=x=>{const w=mt(x),u=a===x.path;return n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>d(x.path),className:ne("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",u?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[n.jsx(ut,{filePath:x.path,className:"h-3.5 w-3.5 flex-shrink-0"}),n.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:{color:w.color},title:c(w.descriptionKey),"aria-label":c(w.descriptionKey),children:w.code}),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:x.path,children:x.path}),ht(x.insertions,x.deletions)]})},x.path)},e[5]=d,e[6]=a,e[7]=c,e[8]=f):f=e[8],g=i.map(f),e[0]=i,e[1]=d,e[2]=a,e[3]=c,e[4]=g}else g=e[4];let p;return e[9]!==g?(p=n.jsx(dt,{outerClassName:"flex-1 min-h-0",className:"px-2 py-2",children:n.jsx("ul",{className:"flex flex-col gap-1",children:g})}),e[9]=g,e[10]=p):p=e[10],p}),jn=o.memo(r=>{const e=pe.c(20),{filePath:i,diff:a,renderSideBySide:d}=r,{t:c}=me(),g=a.original.length>0,p=a.modified.length>0,f=d?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",x=d?"flex flex-col items-center gap-2 flex-1 min-w-0":"flex flex-col items-center gap-2";let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w={contain:"layout"},e[0]=w):w=e[0];let u;e[1]!==a.original||e[2]!==i||e[3]!==g||e[4]!==x||e[5]!==d||e[6]!==c?(u=g&&n.jsxs("div",{className:x,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:c("diffView.image.original")}),n.jsx("img",{src:a.original,alt:c("diffView.image.originalAlt",{path:i}),className:d?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[1]=a.original,e[2]=i,e[3]=g,e[4]=x,e[5]=d,e[6]=c,e[7]=u):u=e[7];let N;e[8]!==a.modified||e[9]!==i||e[10]!==p||e[11]!==g||e[12]!==x||e[13]!==d||e[14]!==c?(N=p&&n.jsxs("div",{className:x,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:c(g?"diffView.image.modified":"diffView.image.new")}),n.jsx("img",{src:a.modified,alt:c("diffView.image.modifiedAlt",{path:i}),className:d?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[8]=a.modified,e[9]=i,e[10]=p,e[11]=g,e[12]=x,e[13]=d,e[14]=c,e[15]=N):N=e[15];let y;return e[16]!==f||e[17]!==u||e[18]!==N?(y=n.jsx("div",{className:"w-full overflow-auto p-4",style:w,children:n.jsxs("div",{className:f,children:[u,N]})}),e[16]=f,e[17]=u,e[18]=N,e[19]=y):y=e[19],y}),Sn=o.memo(r=>{const e=pe.c(16),{filePath:i,diff:a,renderSideBySide:d,wrapLines:c}=r;let g;e[0]!==i?(g=Ut(i)||"text",e[0]=i,e[1]=g):g=e[1];const p=g;if(a.isBinary){let w;return e[2]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(un,{}),e[2]=w):w=e[2],w}if(De(i)){let w;return e[3]!==a||e[4]!==i||e[5]!==d?(w=n.jsx(jn,{filePath:i,diff:a,renderSideBySide:d}),e[3]=a,e[4]=i,e[5]=d,e[6]=w):w=e[6],w}let f;e[7]===Symbol.for("react.memo_cache_sentinel")?(f={contain:"layout"},e[7]=f):f=e[7];let x;return e[8]!==a.fileDiff||e[9]!==a.modified||e[10]!==a.original||e[11]!==i||e[12]!==p||e[13]!==d||e[14]!==c?(x=n.jsx("div",{className:"w-full",style:f,children:n.jsx(Jt,{original:a.original,modified:a.modified,fileDiff:a.fileDiff,language:p,fileName:i,renderSideBySide:d,wrapLines:c,layout:"inline"})}),e[8]=a.fileDiff,e[9]=a.modified,e[10]=a.original,e[11]=i,e[12]=p,e[13]=d,e[14]=c,e[15]=x):x=e[15],x}),Nn=o.memo(r=>{const e=pe.c(7),{filePath:i,staged:a,busyAction:d,disabled:c,onAction:g}=r,{t:p}=me();let f;return e[0]!==d||e[1]!==c||e[2]!==i||e[3]!==g||e[4]!==a||e[5]!==p?(f=n.jsx("div",{className:"flex items-center gap-0.5 rounded-full border border-[var(--interactive-border)]/45 bg-[var(--surface-background)]/95 px-1 py-0.5 shadow-sm backdrop-blur-md",children:a?n.jsx(We,{label:p("gitView.changes.unstageFileAria",{path:i}),icon:"arrow-go-back",loading:d==="unstage",disabled:c,onClick:()=>g("unstage")}):n.jsxs(n.Fragment,{children:[n.jsx(We,{label:p("gitView.changes.revertFileAria",{path:i}),icon:"arrow-go-back",loading:d==="discard",disabled:c,tone:"failure",onClick:()=>g("discard")}),n.jsx(We,{label:p("gitView.changes.stageFileAria",{path:i}),icon:"add",loading:d==="stage",disabled:c,tone:"success",onClick:()=>g("stage")})]})}),e[0]=d,e[1]=c,e[2]=i,e[3]=g,e[4]=a,e[5]=p,e[6]=f):f=e[6],f}),We=r=>{const e=pe.c(14),{label:i,icon:a,loading:d,disabled:c,tone:g,onClick:p}=r,f=g==="failure"&&"text-[var(--status-error)] hover:text-[var(--status-error)]",x=g==="success"&&"text-[var(--status-success)] hover:text-[var(--status-success)]";let w;e[0]!==f||e[1]!==x?(w=ne("h-6 w-6 rounded-none bg-transparent p-0 text-muted-foreground opacity-70 hover:bg-transparent hover:text-foreground hover:opacity-100",f,x),e[0]=f,e[1]=x,e[2]=w):w=e[2];let u;e[3]!==p?(u=D=>{D.stopPropagation(),p()},e[3]=p,e[4]=u):u=e[4];let N;e[5]!==a||e[6]!==d?(N=d?n.jsx(_,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(_,{name:a,className:a==="add"?"size-4":"size-3.5"}),e[5]=a,e[6]=d,e[7]=N):N=e[7];let y;return e[8]!==c||e[9]!==i||e[10]!==w||e[11]!==u||e[12]!==N?(y=n.jsx(ue,{variant:"ghost",size:"sm",className:w,disabled:c,title:i,"aria-label":i,onClick:u,children:N}),e[8]=c,e[9]=i,e[10]=w,e[11]=u,e[12]=N,e[13]=y):y=e[13],y},Fn=o.memo(({directory:r,file:e,layout:i,wrapLines:a,isSelected:d,isExpanded:c,isMounted:g,onSelect:p,onExpandedChange:f,registerSectionRef:x,showOpenInEditorAction:w=!1,isOpeningInEditor:u=!1,onOpenInEditor:N,staged:y=!1,loadFullFiles:D=!1,initialDiffData:T=null})=>{const{t:k}=me(),{git:j}=ct(),M=le(o.useCallback(m=>m.directories.get(r)?.diffCache.get(e.path)??null,[r,e.path])),W=le(m=>m.setDiff),H=le(m=>m.fetchStatus),J=Z(m=>m.setDiffFileLayout),[q,U]=o.useState(0),[V,I]=o.useState(null),[ee,L]=o.useState(!1),[B,P]=o.useState(null),[E,O]=o.useState(!1),[te,X]=o.useState(null),[se,je]=o.useState(null),ie=o.useRef(null),Se=o.useRef(null),ce=o.useMemo(()=>mt(e),[e]),Re=i==="side-by-side",ge=D?"full":"patch",fe=`${e.index}:${e.working_dir}:${e.insertions}:${e.deletions}`,Y=o.useMemo(()=>T||(y?se:te||(M?{original:M.original,modified:M.modified,isBinary:M.isBinary,contextMode:"full"}:null)),[M,T,te,y,se]),Ne=Y?.contextMode===ge,b=o.useCallback(m=>{Se.current=m,x(e.path,m)},[e.path,x]),he=o.useCallback(m=>{f(e.path,m)},[e.path,f]),re=o.useCallback(()=>{p(e.path)},[e.path,p]);o.useEffect(()=>{y?je(null):X(null),I(null),ie.current=null},[fe,y]),o.useEffect(()=>{if(!c||!g)return;if(!r||T||Y&&Ne){ie.current=null,L(!1);return}const m=`${r}::${e.path}::${y?"staged":"unstaged"}::${fe}::${ge}::${q}`;if(ie.current===m)return;ie.current=m,I(null),L(!0);let C=!1;const ae=lt(),Ae=D?cn:fn,Ve=De(e.path)?j.getGitFileDiff(r,{path:e.path,staged:y}):j.getGitDiff(r,{path:e.path,staged:y,contextLines:Ae}),Le=ln,Ee=new Promise((R,$)=>{setTimeout(()=>$(new Error(`Timed out after ${Le}ms`)),Le)});return Promise.race([Ve,Ee]).then(R=>{if(!C){if("diff"in R){const $=gt(e.path,R.diff,ge);y?je($):X($)}else{const $={original:R.original??"",modified:R.modified??"",isBinary:R.isBinary,contextMode:"full"};y?je($):W(r,e.path,$,ae)}L(!1)}}).catch(R=>{if(C)return;const $=R instanceof Error?R.message:String(R);I($),L(!1)}),()=>{C=!0,ie.current===m&&(ie.current=null)}},[ge,Y,Ne,q,r,e.path,fe,j,T,c,g,D,W,y]);const Fe=o.useCallback(()=>{he(!c),re()},[he,re,c]),oe=o.useCallback(async m=>{if(!(!r||B!==null)){P(m);try{m==="stage"?await j.stageGitFile(r,e.path):m==="unstage"?await j.unstageGitFile(r,e.path):await j.revertGitFile(r,e.path,{scope:"working"}),U(C=>C+1),await H(r,j)}catch(C){const ae=m==="unstage"?"gitView.toast.unstageFileFailed":m==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.revertFailed";Ie.error(C instanceof Error?C.message:k(ae))}finally{P(C=>C===m?null:C)}}},[r,H,e.path,B,j,k]);return n.jsxs("div",{ref:b,className:"scroll-mt-9 border-b border-[var(--interactive-border)]/40 last:border-b-0",children:[n.jsx("div",{className:"sticky top-0 z-30 border-b border-[var(--interactive-border)]/35 bg-[var(--surface-elevated)]/90 backdrop-blur-md supports-[backdrop-filter]:bg-[var(--surface-elevated)]/80",children:n.jsxs("div",{role:"button",tabIndex:0,onClick:Fe,onKeyDown:m=>{m.target===m.currentTarget&&(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),Fe())},className:ne("cursor-pointer","group/header relative grid min-h-9 w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2 overflow-hidden px-3 py-2","bg-transparent","text-muted-foreground hover:text-foreground",d?"bg-[var(--interactive-selection)]/35":null),children:[n.jsx("div",{className:"absolute inset-0 pointer-events-none group-hover/header:bg-[var(--interactive-hover)]/50"}),n.jsxs("div",{className:"relative flex min-w-0 flex-1 items-center gap-2",children:[n.jsx("span",{className:"flex size-5 items-center justify-center opacity-70 group-hover/header:opacity-100",children:c?n.jsx(_,{name:"arrow-down-s",className:"size-4"}):n.jsx(_,{name:"arrow-right-s",className:"size-4"})}),n.jsx("span",{className:"typography-micro font-semibold leading-none w-4 text-center uppercase",style:{color:ce.color},title:k(ce.descriptionKey),"aria-label":k(ce.descriptionKey),children:ce.code}),n.jsx("span",{className:"min-w-0 flex-1 overflow-hidden typography-ui-label",title:e.path,children:n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(ut,{filePath:e.path,className:"h-3.5 w-3.5 flex-shrink-0 align-middle"}),(()=>{const m=e.path.lastIndexOf("/");if(m===-1)return n.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:e.path});const C=e.path.slice(0,m),ae=e.path.slice(m+1);return n.jsxs("span",{className:"flex min-w-0 items-baseline overflow-hidden",children:[n.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:C}),n.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[n.jsx("span",{className:"text-muted-foreground",children:"/"}),n.jsx("span",{className:"text-foreground",children:ae})]})]})})()]})})]}),n.jsxs("div",{className:"relative flex shrink-0 items-center justify-self-end gap-2",children:[ht(e.insertions,e.deletions),w&&N?n.jsx(ue,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:k("diffView.actions.openFileInEditorAtChange"),onClick:m=>{m.stopPropagation(),N(e.path,Y)},disabled:u,children:u?n.jsx(_,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(_,{name:"edit",className:"size-3.5"})}):null,n.jsx(ft,{mode:Re?"side-by-side":"unified",onModeChange:m=>{const C=m==="side-by-side"?"side-by-side":"inline";J(e.path,C)},className:"opacity-70"})]})]})}),c&&n.jsxs("div",{className:"relative bg-background overflow-hidden",children:[!g&&!V?n.jsx("div",{className:"h-40 border border-border/40 bg-background/40"}):null,V?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:k("diffView.state.failedToLoadDiff")}),n.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:V}),n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>U(m=>m+1),children:k("diffView.actions.retry")})]}):null,g&&ee&&!Y&&!V?n.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx(_,{name:"loader-4",className:"size-4 animate-spin"}),k("diffView.state.loadingDiff")]}):null,g&&Y&&!E&&e.insertions+e.deletions>nt?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:k("diffView.state.largeDiff",{count:e.insertions+e.deletions})}),n.jsx("div",{className:"typography-meta text-muted-foreground",children:k("diffView.state.largeDiffDescription")}),n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>O(!0),children:k("diffView.actions.renderAnyway")})]}):null,g&&Y&&(E||e.insertions+e.deletions<=nt)?n.jsxs(n.Fragment,{children:[n.jsx(Sn,{filePath:e.path,diff:Y,renderSideBySide:Re,wrapLines:a}),n.jsx("div",{className:"pointer-events-none absolute bottom-3 right-3 z-20",children:n.jsx("div",{className:"pointer-events-auto",children:n.jsx(Nn,{filePath:e.path,staged:y,busyAction:B,disabled:B!==null,onAction:oe})})})]}):null]})]})}),zi=({hideStackedFileSidebar:r=!1,stackedDefaultCollapsedAll:e=!1,pinSelectedFileHeaderToTopOnNavigate:i=!1,showOpenInEditorAction:a=!1,diffScope:d="all",onDiffScopeChange:c,targetFilePath:g=null,flushContent:p=!1})=>{const{t:f}=me(),{git:x,files:w}=ct(),u=Mt(),N=Z(t=>t.openContextSurface),y=en(t=>t.requestSource),{screenWidth:D,isMobile:T}=It(),k=_t(u??null),j=zt(u??null),M=Bt(u??null),W=le(t=>t.setActiveDirectory),H=le(t=>t.ensureStatus),J=le(t=>t.fetchStatus),q=le(t=>t.clearDiffCache),U=le(t=>t.setDiff),[V,I]=o.useState(null),[ee,L]=o.useState(!1),[B,P]=o.useState(null),[E,O]=o.useState(()=>new Set),[te,X]=o.useState(()=>new Set),[se,je]=o.useState(!1),[ie,Se]=o.useState(0),[ce,Re]=o.useState(()=>new Map),[ge,fe]=o.useState(!1),[Y,Ne]=o.useState(!1),[b,he]=o.useState(d);o.useEffect(()=>{he(d)},[d]);const re=Z(t=>t.pendingDiffFile),Fe=Z(t=>t.pendingDiffStaged),oe=Z(t=>t.pendingDiffScope),m=Z(t=>t.setPendingDiffFile),C=Z(t=>t.diffLayoutPreference),ae=Z(t=>t.diffFileLayout),Ae=Z(t=>t.setDiffFileLayout),Ve=Z(t=>t.diffWrapLines),Le=Z(t=>t.setDiffWrapLines),Ee=Z(t=>t.openContextFileAtLine),R=Je(t=>t.currentSessionId),$=Pt(R??"",u??void 0),_e=Ve,ze=b==="staged"?!0:b==="working"?!1:null,Te=ze??ee,Be=T||D<=768,xt=!!R&&b!=="turn"&&!Be&&!Ze(),wt=b!=="turn"&&!Be&&!Ze(),yt=!r&&!Be&&D>=1024,xe=o.useRef(null),Ce=o.useRef(new Map),de=o.useRef(null),z=o.useRef(null),we=o.useRef(!1),ye=o.useRef(null),He=o.useRef(null),Pe=o.useRef(null),Oe=o.useRef(null),qe=o.useCallback(()=>{const t=xe.current;if(!t)return null;const s=t.getBoundingClientRect().top,l=[];for(const[h,v]of Ce.current)v&&l.push({path:h,top:v.getBoundingClientRect().top});return et(s,l)},[]),be=o.useCallback(()=>{de.current=null,we.current=!1,P(null),z.current!==null&&(window.cancelAnimationFrame(z.current),z.current=null)},[]),ve=o.useCallback(t=>{O(s=>{if(s.has(t))return s;const l=new Set(s);return l.add(t),l})},[]),ke=o.useMemo(()=>{for(let t=$.length-1;t>=0;t-=1){const s=$[t];if(s.role==="user")return wn(s.summary?.diffs)}return[]},[$]),bt=o.useMemo(()=>{const t=new Map;for(const s of ke)if(s.file){if(typeof s.patch=="string"){t.set(s.file,gt(s.file,s.patch,"patch"));continue}t.set(s.file,{original:s.before??"",modified:s.after??"",contextMode:"full"})}return t},[ke]),S=o.useMemo(()=>{if(b==="turn")return ke.map(l=>({path:l.file??"",index:"",working_dir:yn(l.status),insertions:l.additions??0,deletions:l.deletions??0,isNew:l.status==="added"})).filter(l=>l.path).sort((l,h)=>l.path.localeCompare(h.path));if(!j?.files)return[];const t=j.diffStats??{},s=b==="staged"?it:b==="working"?rt:()=>!0;return j.files.filter(s).map(l=>({...l,insertions:t[l.path]?.insertions??0,deletions:t[l.path]?.deletions??0,isNew:gn(l)})).sort((l,h)=>l.path.localeCompare(h.path))},[b,ke,j]),vt=o.useMemo(()=>j?.files?j.files.filter(rt).length:0,[j]),jt=o.useMemo(()=>j?.files?j.files.filter(it).length:0,[j]),St=ke.length,$e=o.useMemo(()=>S.map(t=>t.path).join("\0"),[S]);o.useEffect(()=>{const t=$e?$e.split("\0"):[],s=new Set(t),l=`${u??""}:${b}:${e?"collapsed":"default"}`,h=He.current!==l;He.current=l,O(v=>{if(h){const A=e?0:dn(t.length);return new Set(t.slice(0,A))}let G=!1;const F=new Set;for(const A of v){if(!s.has(A)){G=!0;continue}F.add(A)}return G?F:v}),X(v=>{if(h)return new Set;let G=!1;const F=new Set;for(const A of v){if(!s.has(A)){G=!0;continue}F.add(A)}return G?F:v})},[b,$e,u,e]);const Ue=o.useCallback(()=>{ye.current=null;const t=xe.current;if(!t)return;const s=t.getBoundingClientRect(),l=s.top-st,h=s.bottom+st,v={},G=[];for(const[F,A]of Ce.current){if(!A)continue;const K=A.getBoundingClientRect();G.push({path:F,top:K.top}),E.has(F)&&(K.bottom<l||K.top>h||(v[F]=!0))}Pe.current=et(s.top,G),X(F=>{let A=!1;const K=new Set(F);for(const Qe of Object.keys(v))K.has(Qe)||(K.add(Qe),A=!0);return A?K:F})},[E]),Q=o.useCallback(()=>{typeof window>"u"||ye.current===null&&(ye.current=window.requestAnimationFrame(Ue))},[Ue]);o.useEffect(()=>{const t=xe.current;if(t)return Q(),t.addEventListener("scroll",Q,{passive:!0}),window.addEventListener("resize",Q),()=>{t.removeEventListener("scroll",Q),window.removeEventListener("resize",Q),ye.current!==null&&(window.cancelAnimationFrame(ye.current),ye.current=null)}},[S,E,Q]);const Ge=o.useCallback(t=>{const s=ae[t.path];if(s)return s;if(C==="inline")return"inline";if(C==="side-by-side")return"side-by-side";const l=D<an;return t.isNew||l?"inline":"side-by-side"},[ae,C,D]),Xe=o.useMemo(()=>S.length===0?null:S.every(t=>Ge(t)==="side-by-side")?"side-by-side":"inline",[S,Ge]);o.useEffect(()=>{u&&(W(u),H(u,x))},[u,W,H,x]),o.useEffect(()=>{if(u)return Ot.onGitRefreshHint(t=>{ot(t.directory)===ot(u)&&(t.paths?.length&&(Oe.current=qe()??Pe.current,q(u,t.paths),Re(s=>{const l=new Map(s);for(const h of t.paths??[])l.set(h,(l.get(h)??0)+1);return l})),J(u,x,{silent:!0}))})},[qe,q,u,J,x]),o.useLayoutEffect(()=>{const t=Oe.current;if(!t)return;Oe.current=null;const s=xe.current,l=Ce.current.get(t.path);if(!s||!l)return;const h=s.getBoundingClientRect().top,v=l.getBoundingClientRect().top-h;s.scrollTop=on(s.scrollTop,t.topOffset,v,s.scrollHeight-s.clientHeight),Pe.current=t},[ce]),o.useEffect(()=>{b!=="all"&&!oe||re&&(oe&&he(oe),I(re),L(oe==="staged"||!oe&&Fe),m(null),we.current=!0,de.current=re,ve(re),Se(t=>t+1))},[b,ve,re,oe,Fe,m]),o.useEffect(()=>{if(b==="all")return;const t=g?.trim();t&&(I(t),L(b==="staged"),we.current=!0,de.current=t,ve(t),Se(s=>s+1))},[b,ve,g]),o.useEffect(()=>{if(!V)return;S.some(s=>s.path===V)||(I(null),L(!1))},[S,V]);const Nt=o.useCallback((t,s)=>{const l=Ce.current;s?l.set(t,s):l.delete(t),Q()},[Q]),Ft=o.useCallback((t,s)=>{be(),O(l=>{const h=l.has(t);if(s===h)return l;const v=new Set(l);return s?v.add(t):v.delete(t),v}),s||X(l=>{if(!l.has(t))return l;const h=new Set(l);return h.delete(t),h}),Q()},[be,Q]),Ct=o.useCallback(()=>{be(),O(t=>t.size>0?new Set:new Set(S.map(s=>s.path))),X(new Set),Q()},[be,S,Q]),kt=o.useCallback(async t=>{if(!R)return;const s=Je.getState().getDirectoryForSession(R)||u||"";if(!s){Ie.error(f("diffView.reviewDialog.toast.noSessionDirectory"));return}Ne(!0);try{await $t({originalSessionID:R,directory:s,providerID:t.providerID,modelID:t.modelID,agent:t.agent||void 0,variant:t.variant||void 0,generateHandoff:t.generateHandoff,returnAfterHandoffRequest:t.generateHandoff,autoReview:t.autoReview}),fe(!1)}catch(l){console.error("[review-flow] failed to start review flow",l),Ie.error(l instanceof Error?l.message:f("diffView.reviewDialog.toast.startFailed"))}finally{Ne(!1)}},[R,u,f]),Me=o.useCallback(t=>{const s=Ce.current.get(t),l=xe.current;if(!s||!l)return!1;const h=s.getBoundingClientRect().top-l.getBoundingClientRect().top;return l.scrollTo({top:l.scrollTop+h,behavior:"auto"}),!0},[]);o.useEffect(()=>{if(!de.current)return;let s=0;const l=20;let h=!1;const v=(F=!0)=>{h||(h=!0,de.current=null,we.current=!1,F&&P(null),z.current!==null&&(window.cancelAnimationFrame(z.current),z.current=null))},G=()=>{if(h){z.current=null;return}const F=de.current;if(!F){v(),z.current=null;return}if(!Me(F)){s+=1,s<l?z.current=window.requestAnimationFrame(G):(v(),z.current=null);return}if(i&&we.current){P(F),v(!1);return}v()};return z.current=window.requestAnimationFrame(G),()=>{h=!0,z.current!==null&&(window.cancelAnimationFrame(z.current),z.current=null)}},[i,ie,Me]);const Dt=o.useCallback(t=>{},[]),Rt=o.useCallback(t=>{be(),I(t),L(!1),we.current=!0,de.current=t,ve(t),Se(s=>s+1),Me(t)},[be,ve,Me]),At=o.useCallback(t=>{const s=t==="side-by-side"?"side-by-side":"inline";S.forEach(l=>{Ae(l.path,s)})},[S,Ae]),[Vt,Ye]=o.useState(null),Lt=o.useCallback(async(t,s)=>{if(!u||!t)return;Ye(t);const l=lt();try{let h=null;if(s?.patch&&!s.isBinary&&!De(t)?h=tt(s.patch):s&&s.contextMode==="full"&&!s.isBinary&&!De(t)&&(h=at(s.original,s.modified)),h===null)try{const K=await x.getGitDiff(u,{path:t,staged:Te,contextLines:3});h=tt(K.diff)}catch{h=null}let v=s;if(h===null||!v){const K=await x.getGitFileDiff(u,{path:t,staged:Te});v={original:K.original??"",modified:K.modified??"",isBinary:K.isBinary},Te||U(u,t,v,l)}const G=h??(v.isBinary||De(t)?1:at(v.original,v.modified)),F=hn(u,t),A=await tn(w,F,{directory:u});if(!A.ok){Ie.error(nn(A.reason));return}Ee(u,F,G,1)}finally{Ye(h=>h===t?null:h)}},[Te,u,w,x,Ee,U]),Et=()=>{if(!u)return null;const t=s=>ze!==null?ze:ee&&s===V;return n.jsxs("div",{className:ne("flex min-w-0 flex-1 min-h-0 h-full",p?"gap-0":"gap-3 px-3 pb-3 pt-2"),children:[yt&&n.jsxs("section",{className:"hidden lg:flex w-72 flex-col rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/40",children:[n.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:f("diffView.section.files")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:S.length})]}),n.jsx(vn,{changedFiles:S,selectedFile:null,onSelectFile:Rt})]}),n.jsx("div",{className:"relative flex-1 min-w-0 min-h-0 h-full",children:n.jsx(dt,{ref:xe,outerClassName:"min-h-0 h-full",className:"[overflow-anchor:none] pb-16",disableHorizontal:!0,observeMutations:!1,preventOverscroll:!0,"data-diff-virtual-root":!0,children:n.jsx("div",{className:"flex flex-col [overflow-anchor:none]","data-diff-virtual-content":!0,children:S.map(s=>n.jsx(Fn,{directory:u,file:s,layout:Ge(s),wrapLines:_e,isSelected:!1,isExpanded:E.has(s.path),isMounted:te.has(s.path)||s.path===B,onSelect:Dt,onExpandedChange:Ft,registerSectionRef:Nt,showOpenInEditorAction:a&&b!=="turn",isOpeningInEditor:Vt===s.path,onOpenInEditor:(l,h)=>{Lt(l,h)},staged:t(s.path),loadFullFiles:se,initialDiffData:b==="turn"?bt.get(s.path)??null:null},`${s.path}:${ce.get(s.path)??0}`))})})})]})},Tt=()=>u?b!=="turn"&&M&&!j?n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(_,{name:"loader-4",className:"size-4 animate-spin"}),f("diffView.state.loadingRepositoryStatus")]}):b!=="turn"&&k===!1?n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:f("diffView.state.notGitRepository")}):S.length===0?n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:f(b==="turn"?"diffView.state.noLastTurnChanges":"diffView.state.cleanWorkingTree")}):Et():n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:f("diffView.state.selectSessionDirectory")});return n.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background",children:[n.jsxs("div",{className:"@container/diff-toolbar flex min-w-0 items-center gap-2 px-3 py-2 bg-background",children:[!T&&(b==="working"||b==="staged"||b==="turn"?n.jsx(bn,{scope:b,workingCount:vt,stagedCount:jt,turnCount:St,onScopeChange:t=>{he(t),c?.(t)}}):n.jsx("div",{className:"flex items-center gap-1 rounded-md px-2 py-1 text-muted-foreground shrink-0",children:n.jsx("span",{className:"typography-ui-label font-semibold text-foreground",children:M&&!j?f("diffView.state.loadingChanges"):S.length===1?f("diffView.summary.changedFilesSingle",{count:S.length}):f("diffView.summary.changedFilesPlural",{count:S.length})})})),S.length>0&&n.jsxs(ue,{variant:"ghost",size:"sm",onClick:Ct,className:ne("diff-toolbar__expand-button h-7 flex-shrink-0 gap-1 px-1.5 text-muted-foreground hover:text-foreground","ml-auto"),title:E.size>0?f("diffView.actions.collapseAll"):f("diffView.actions.expandAll"),children:[n.jsx(_,{name:"expand-up-down",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:E.size>0?f("diffView.actions.collapseAll"):f("diffView.actions.expandAll")})]}),S.length>0&&xt&&n.jsxs(ue,{variant:"default",size:"sm",onClick:()=>fe(!0),disabled:Y,className:"diff-toolbar__review-button h-7 flex-shrink-0 gap-1.5 px-2","aria-label":f("diffView.actions.reviewAria"),children:[Y?n.jsx(_,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx(_,{name:"search-eye",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__review-label typography-ui-label",children:f("diffView.actions.review")})]}),S.length>0&&wt&&n.jsxs(ue,{variant:"outline",size:"sm",onClick:()=>{const t=u??"";y(t,{kind:"working-tree",scope:b==="staged"||b==="working"?b:"all"}),N(t,"walkthrough")},className:ne("diff-toolbar__walkthrough-button h-7 flex-shrink-0 gap-1.5 px-2",sn),"aria-label":f("walkthrough.action.open"),children:[n.jsx(_,{name:"route",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__walkthrough-label typography-ui-label",children:f("walkthrough.action.open")})]}),S.length>0&&n.jsxs(Gt,{children:[n.jsx(Kt,{asChild:!0,children:n.jsx(ue,{variant:"ghost",size:"sm",onClick:()=>je(t=>!t),"aria-pressed":se,"aria-label":f(se?"diffView.actions.disableFullFiles":"diffView.actions.loadFullFiles"),className:ne("h-7 w-7 flex-shrink-0 p-0 text-muted-foreground hover:text-foreground",se&&"bg-interactive-selection text-interactive-selection-foreground"),children:n.jsx(_,{name:"file-download",className:"size-4"})})}),n.jsx(Wt,{children:n.jsx("p",{children:f(se?"diffView.actions.disableFullFiles":"diffView.actions.loadFullFiles")})})]}),S.length>0&&n.jsx(ue,{variant:"ghost",size:"sm",onClick:()=>Le(!Ve),className:ne("h-5 w-5 p-0 transition-opacity",_e?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:f(_e?"diffView.actions.disableLineWrap":"diffView.actions.enableLineWrap"),children:n.jsx(_,{name:"text-wrap",className:"size-4"})}),Xe&&n.jsx(ft,{mode:Xe==="side-by-side"?"side-by-side":"unified",onModeChange:At})]}),n.jsx(Ht,{open:ge,onOpenChange:fe,projectDirectory:u??null,submitting:Y,onConfirm:kt}),Tt()]})};export{zi as DiffView};